aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 62b779008..5756e9754 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -14,8 +14,8 @@ use crate::{
14 from_assoc_type_id, 14 from_assoc_type_id,
15 primitive::UintTy, 15 primitive::UintTy,
16 traits::{Canonical, Obligation}, 16 traits::{Canonical, Obligation},
17 AliasTy, CallableDefId, FnPointer, GenericPredicate, InEnvironment, OpaqueTy, ProjectionTy, 17 AliasTy, CallableDefId, FnPointer, InEnvironment, OpaqueTy, ProjectionTy, Scalar, Substitution,
18 Scalar, Substitution, TraitRef, Ty, 18 TraitRef, Ty, WhereClause,
19}; 19};
20 20
21use super::interner::*; 21use super::interner::*;
@@ -304,28 +304,28 @@ impl ToChalk for TypeAliasAsValue {
304 } 304 }
305} 305}
306 306
307impl ToChalk for GenericPredicate { 307impl ToChalk for WhereClause {
308 type Chalk = chalk_ir::QuantifiedWhereClause<Interner>; 308 type Chalk = chalk_ir::QuantifiedWhereClause<Interner>;
309 309
310 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::QuantifiedWhereClause<Interner> { 310 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::QuantifiedWhereClause<Interner> {
311 match self { 311 match self {
312 GenericPredicate::Implemented(trait_ref) => { 312 WhereClause::Implemented(trait_ref) => {
313 let chalk_trait_ref = trait_ref.to_chalk(db); 313 let chalk_trait_ref = trait_ref.to_chalk(db);
314 let chalk_trait_ref = chalk_trait_ref.shifted_in(&Interner); 314 let chalk_trait_ref = chalk_trait_ref.shifted_in(&Interner);
315 make_binders(chalk_ir::WhereClause::Implemented(chalk_trait_ref), 0) 315 make_binders(chalk_ir::WhereClause::Implemented(chalk_trait_ref), 0)
316 } 316 }
317 GenericPredicate::AliasEq(alias_eq) => make_binders( 317 WhereClause::AliasEq(alias_eq) => make_binders(
318 chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db).shifted_in(&Interner)), 318 chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db).shifted_in(&Interner)),
319 0, 319 0,
320 ), 320 ),
321 GenericPredicate::Error => panic!("tried passing GenericPredicate::Error to Chalk"), 321 WhereClause::Error => panic!("tried passing GenericPredicate::Error to Chalk"),
322 } 322 }
323 } 323 }
324 324
325 fn from_chalk( 325 fn from_chalk(
326 db: &dyn HirDatabase, 326 db: &dyn HirDatabase,
327 where_clause: chalk_ir::QuantifiedWhereClause<Interner>, 327 where_clause: chalk_ir::QuantifiedWhereClause<Interner>,
328 ) -> GenericPredicate { 328 ) -> WhereClause {
329 // we don't produce any where clauses with binders and can't currently deal with them 329 // we don't produce any where clauses with binders and can't currently deal with them
330 match where_clause 330 match where_clause
331 .skip_binders() 331 .skip_binders()
@@ -333,11 +333,9 @@ impl ToChalk for GenericPredicate {
333 .shifted_out(&Interner) 333 .shifted_out(&Interner)
334 .expect("unexpected bound vars in where clause") 334 .expect("unexpected bound vars in where clause")
335 { 335 {
336 chalk_ir::WhereClause::Implemented(tr) => { 336 chalk_ir::WhereClause::Implemented(tr) => WhereClause::Implemented(from_chalk(db, tr)),
337 GenericPredicate::Implemented(from_chalk(db, tr))
338 }
339 chalk_ir::WhereClause::AliasEq(alias_eq) => { 337 chalk_ir::WhereClause::AliasEq(alias_eq) => {
340 GenericPredicate::AliasEq(from_chalk(db, alias_eq)) 338 WhereClause::AliasEq(from_chalk(db, alias_eq))
341 } 339 }
342 340
343 chalk_ir::WhereClause::LifetimeOutlives(_) => { 341 chalk_ir::WhereClause::LifetimeOutlives(_) => {
@@ -534,13 +532,13 @@ pub(super) fn convert_where_clauses(
534 532
535pub(super) fn generic_predicate_to_inline_bound( 533pub(super) fn generic_predicate_to_inline_bound(
536 db: &dyn HirDatabase, 534 db: &dyn HirDatabase,
537 pred: &GenericPredicate, 535 pred: &WhereClause,
538 self_ty: &Ty, 536 self_ty: &Ty,
539) -> Option<rust_ir::InlineBound<Interner>> { 537) -> Option<rust_ir::InlineBound<Interner>> {
540 // An InlineBound is like a GenericPredicate, except the self type is left out. 538 // An InlineBound is like a GenericPredicate, except the self type is left out.
541 // We don't have a special type for this, but Chalk does. 539 // We don't have a special type for this, but Chalk does.
542 match pred { 540 match pred {
543 GenericPredicate::Implemented(trait_ref) => { 541 WhereClause::Implemented(trait_ref) => {
544 if &trait_ref.substitution[0] != self_ty { 542 if &trait_ref.substitution[0] != self_ty {
545 // we can only convert predicates back to type bounds if they 543 // we can only convert predicates back to type bounds if they
546 // have the expected self type 544 // have the expected self type
@@ -553,7 +551,7 @@ pub(super) fn generic_predicate_to_inline_bound(
553 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; 551 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self };
554 Some(rust_ir::InlineBound::TraitBound(trait_bound)) 552 Some(rust_ir::InlineBound::TraitBound(trait_bound))
555 } 553 }
556 GenericPredicate::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { 554 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => {
557 if &projection_ty.substitution[0] != self_ty { 555 if &projection_ty.substitution[0] != self_ty {
558 return None; 556 return None;
559 } 557 }