diff options
author | Florian Diebold <[email protected]> | 2021-04-05 16:45:18 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 18:19:18 +0100 |
commit | ad20f00844cec9c794e34869be163673ebbed182 (patch) | |
tree | 0f37d26295bc9a8372d09df1612bd08a6d19ff72 /crates/hir_ty/src/traits | |
parent | 69714d36e6617800f3edea174f5d6f76c985ad4c (diff) |
Use VariableKinds in Binders
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 22 |
2 files changed, 14 insertions, 18 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 47867f77e..dff87ef70 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -184,7 +184,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
184 | .db | 184 | .db |
185 | .return_type_impl_traits(func) | 185 | .return_type_impl_traits(func) |
186 | .expect("impl trait id without impl traits"); | 186 | .expect("impl trait id without impl traits"); |
187 | let data = &datas.skip_binders().impl_traits[idx as usize]; | 187 | let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders(); |
188 | let data = &datas.impl_traits[idx as usize]; | ||
188 | let bound = OpaqueTyDatumBound { | 189 | let bound = OpaqueTyDatumBound { |
189 | bounds: make_binders( | 190 | bounds: make_binders( |
190 | data.bounds | 191 | data.bounds |
@@ -197,8 +198,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
197 | ), | 198 | ), |
198 | where_clauses: make_binders(vec![], 0), | 199 | where_clauses: make_binders(vec![], 0), |
199 | }; | 200 | }; |
200 | let num_vars = datas.num_binders; | 201 | chalk_ir::Binders::new(binders, bound) |
201 | make_binders(bound, num_vars) | ||
202 | } | 202 | } |
203 | crate::ImplTraitId::AsyncBlockTypeImplTrait(..) => { | 203 | crate::ImplTraitId::AsyncBlockTypeImplTrait(..) => { |
204 | if let Some((future_trait, future_output)) = self | 204 | if let Some((future_trait, future_output)) = self |
@@ -626,7 +626,7 @@ fn type_alias_associated_ty_value( | |||
626 | let value = rust_ir::AssociatedTyValue { | 626 | let value = rust_ir::AssociatedTyValue { |
627 | impl_id: impl_id.to_chalk(db), | 627 | impl_id: impl_id.to_chalk(db), |
628 | associated_ty_id: to_assoc_type_id(assoc_ty), | 628 | associated_ty_id: to_assoc_type_id(assoc_ty), |
629 | value: make_binders(value_bound, binders), | 629 | value: chalk_ir::Binders::new(binders, value_bound), |
630 | }; | 630 | }; |
631 | Arc::new(value) | 631 | Arc::new(value) |
632 | } | 632 | } |
@@ -656,7 +656,7 @@ pub(crate) fn fn_def_datum_query( | |||
656 | let datum = FnDefDatum { | 656 | let datum = FnDefDatum { |
657 | id: fn_def_id, | 657 | id: fn_def_id, |
658 | sig: chalk_ir::FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: sig.is_varargs }, | 658 | sig: chalk_ir::FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: sig.is_varargs }, |
659 | binders: make_binders(bound, binders), | 659 | binders: chalk_ir::Binders::new(binders, bound), |
660 | }; | 660 | }; |
661 | Arc::new(datum) | 661 | Arc::new(datum) |
662 | } | 662 | } |
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 | } |