aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/lib.rs12
-rw-r--r--crates/hir_ty/src/lower.rs8
-rw-r--r--crates/hir_ty/src/traits/chalk.rs8
3 files changed, 12 insertions, 16 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 6d5123cf1..61f5adbc4 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -92,13 +92,11 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option<usize> {
92 generics(db.upcast(), id.parent).param_idx(id) 92 generics(db.upcast(), id.parent).param_idx(id)
93} 93}
94 94
95impl<T> Binders<T> { 95pub fn wrap_empty_binders<T>(value: T) -> Binders<T>
96 pub fn wrap_empty(value: T) -> Self 96where
97 where 97 T: TypeWalk,
98 T: TypeWalk, 98{
99 { 99 Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
100 Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
101 }
102} 100}
103 101
104impl<T: TypeWalk> Binders<T> { 102impl<T: TypeWalk> Binders<T> {
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 48c26f471..6cef8095f 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -384,7 +384,9 @@ impl<'a> TyLoweringContext<'a> {
384 1, 384 1,
385 QuantifiedWhereClauses::from_iter( 385 QuantifiedWhereClauses::from_iter(
386 &Interner, 386 &Interner,
387 Some(Binders::wrap_empty(WhereClause::Implemented(trait_ref))), 387 Some(crate::wrap_empty_binders(WhereClause::Implemented(
388 trait_ref,
389 ))),
388 ), 390 ),
389 ), 391 ),
390 }; 392 };
@@ -720,7 +722,7 @@ impl<'a> TyLoweringContext<'a> {
720 let trait_ref = match bound { 722 let trait_ref = match bound {
721 TypeBound::Path(path) => { 723 TypeBound::Path(path) => {
722 bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); 724 bindings = self.lower_trait_ref_from_path(path, Some(self_ty));
723 bindings.clone().map(WhereClause::Implemented).map(|b| Binders::wrap_empty(b)) 725 bindings.clone().map(WhereClause::Implemented).map(|b| crate::wrap_empty_binders(b))
724 } 726 }
725 TypeBound::Lifetime(_) => None, 727 TypeBound::Lifetime(_) => None,
726 TypeBound::Error => None, 728 TypeBound::Error => None,
@@ -767,7 +769,7 @@ impl<'a> TyLoweringContext<'a> {
767 let ty = self.lower_ty(type_ref); 769 let ty = self.lower_ty(type_ref);
768 let alias_eq = 770 let alias_eq =
769 AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty }; 771 AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty };
770 preds.push(Binders::wrap_empty(WhereClause::AliasEq(alias_eq))); 772 preds.push(crate::wrap_empty_binders(WhereClause::AliasEq(alias_eq)));
771 } 773 }
772 for bound in &binding.bounds { 774 for bound in &binding.bounds {
773 preds.extend(self.lower_type_bound( 775 preds.extend(self.lower_type_bound(
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 075e82f4b..5a8b5cd86 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -246,8 +246,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
246 let bound = OpaqueTyDatumBound { 246 let bound = OpaqueTyDatumBound {
247 bounds: make_binders( 247 bounds: make_binders(
248 vec![ 248 vec![
249 wrap_in_empty_binders(impl_bound).to_chalk(self.db), 249 crate::wrap_empty_binders(impl_bound).to_chalk(self.db),
250 wrap_in_empty_binders(proj_bound).to_chalk(self.db), 250 crate::wrap_empty_binders(proj_bound).to_chalk(self.db),
251 ], 251 ],
252 1, 252 1,
253 ), 253 ),
@@ -723,7 +723,3 @@ impl From<crate::db::InternedClosureId> for chalk_ir::ClosureId<Interner> {
723 chalk_ir::ClosureId(id.as_intern_id()) 723 chalk_ir::ClosureId(id.as_intern_id())
724 } 724 }
725} 725}
726
727fn wrap_in_empty_binders<T: crate::TypeWalk>(value: T) -> crate::Binders<T> {
728 crate::Binders::wrap_empty(value)
729}