aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk/mapping.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-05 16:45:18 +0100
committerFlorian Diebold <[email protected]>2021-04-05 18:19:18 +0100
commitad20f00844cec9c794e34869be163673ebbed182 (patch)
tree0f37d26295bc9a8372d09df1612bd08a6d19ff72 /crates/hir_ty/src/traits/chalk/mapping.rs
parent69714d36e6617800f3edea174f5d6f76c985ad4c (diff)
Use VariableKinds in Binders
Diffstat (limited to 'crates/hir_ty/src/traits/chalk/mapping.rs')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 72458f367..2c7407c7c 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -99,7 +99,7 @@ impl ToChalk for Ty {
99 bounds.interned().iter().cloned().map(|p| p.to_chalk(db)), 99 bounds.interned().iter().cloned().map(|p| p.to_chalk(db)),
100 ); 100 );
101 let bounded_ty = chalk_ir::DynTy { 101 let bounded_ty = chalk_ir::DynTy {
102 bounds: make_binders(where_clauses, binders), 102 bounds: chalk_ir::Binders::new(binders, where_clauses),
103 lifetime: LifetimeData::Static.intern(&Interner), 103 lifetime: LifetimeData::Static.intern(&Interner),
104 }; 104 };
105 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) 105 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
@@ -149,7 +149,7 @@ impl ToChalk for Ty {
149 .map(|c| from_chalk(db, c.clone())); 149 .map(|c| from_chalk(db, c.clone()));
150 TyKind::Dyn(crate::DynTy { 150 TyKind::Dyn(crate::DynTy {
151 bounds: crate::Binders::new( 151 bounds: crate::Binders::new(
152 1, 152 where_clauses.bounds.binders.clone(),
153 crate::QuantifiedWhereClauses::from_iter(&Interner, bounds), 153 crate::QuantifiedWhereClauses::from_iter(&Interner, bounds),
154 ), 154 ),
155 }) 155 })
@@ -488,19 +488,12 @@ where
488 488
489 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T::Chalk> { 489 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T::Chalk> {
490 let (value, binders) = self.into_value_and_skipped_binders(); 490 let (value, binders) = self.into_value_and_skipped_binders();
491 chalk_ir::Binders::new( 491 chalk_ir::Binders::new(binders, value.to_chalk(db))
492 chalk_ir::VariableKinds::from_iter(
493 &Interner,
494 std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General))
495 .take(binders),
496 ),
497 value.to_chalk(db),
498 )
499 } 492 }
500 493
501 fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T::Chalk>) -> crate::Binders<T> { 494 fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T::Chalk>) -> crate::Binders<T> {
502 let (v, b) = binders.into_value_and_skipped_binders(); 495 let (v, b) = binders.into_value_and_skipped_binders();
503 crate::Binders::new(b.len(&Interner), from_chalk(db, v)) 496 crate::Binders::new(b, from_chalk(db, v))
504 } 497 }
505} 498}
506 499
@@ -552,7 +545,7 @@ pub(super) fn generic_predicate_to_inline_bound(
552 .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) 545 .map(|ty| ty.clone().to_chalk(db).cast(&Interner))
553 .collect(); 546 .collect();
554 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; 547 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self };
555 Some(make_binders(rust_ir::InlineBound::TraitBound(trait_bound), binders)) 548 Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound)))
556 } 549 }
557 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { 550 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => {
558 if projection_ty.self_type_parameter(&Interner) != &self_ty_shifted_in { 551 if projection_ty.self_type_parameter(&Interner) != &self_ty_shifted_in {
@@ -569,7 +562,10 @@ pub(super) fn generic_predicate_to_inline_bound(
569 associated_ty_id: projection_ty.associated_ty_id, 562 associated_ty_id: projection_ty.associated_ty_id,
570 parameters: Vec::new(), // FIXME we don't support generic associated types yet 563 parameters: Vec::new(), // FIXME we don't support generic associated types yet
571 }; 564 };
572 Some(make_binders(rust_ir::InlineBound::AliasEqBound(alias_eq_bound), binders)) 565 Some(chalk_ir::Binders::new(
566 binders,
567 rust_ir::InlineBound::AliasEqBound(alias_eq_bound),
568 ))
573 } 569 }
574 _ => None, 570 _ => None,
575 } 571 }