aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/method_resolution.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/method_resolution.rs')
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index 533c6ccfb..74a0bc7db 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -20,7 +20,8 @@ use crate::{
20 db::HirDatabase, 20 db::HirDatabase,
21 primitive::{FloatBitness, Uncertain}, 21 primitive::{FloatBitness, Uncertain},
22 utils::all_super_traits, 22 utils::all_super_traits,
23 ApplicationTy, Canonical, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, TypeWalk, 23 ApplicationTy, Canonical, DebruijnIndex, InEnvironment, TraitEnvironment, TraitRef, Ty,
24 TypeCtor, TypeWalk,
24}; 25};
25 26
26/// This is used as a key for indexing impls. 27/// This is used as a key for indexing impls.
@@ -507,8 +508,9 @@ pub(crate) fn inherent_impl_substs(
507) -> Option<Substs> { 508) -> Option<Substs> {
508 // we create a var for each type parameter of the impl; we need to keep in 509 // we create a var for each type parameter of the impl; we need to keep in
509 // mind here that `self_ty` might have vars of its own 510 // mind here that `self_ty` might have vars of its own
510 let vars = 511 let vars = Substs::build_for_def(db, impl_id)
511 Substs::build_for_def(db, impl_id).fill_with_bound_vars(self_ty.num_vars as u32).build(); 512 .fill_with_bound_vars(DebruijnIndex::INNERMOST, self_ty.num_vars)
513 .build();
512 let self_ty_with_vars = db.impl_self_ty(impl_id).subst(&vars); 514 let self_ty_with_vars = db.impl_self_ty(impl_id).subst(&vars);
513 let self_ty_with_vars = 515 let self_ty_with_vars =
514 Canonical { num_vars: vars.len() + self_ty.num_vars, value: self_ty_with_vars }; 516 Canonical { num_vars: vars.len() + self_ty.num_vars, value: self_ty_with_vars };
@@ -526,8 +528,8 @@ pub(crate) fn inherent_impl_substs(
526fn fallback_bound_vars(s: Substs, num_vars_to_keep: usize) -> Substs { 528fn fallback_bound_vars(s: Substs, num_vars_to_keep: usize) -> Substs {
527 s.fold_binders( 529 s.fold_binders(
528 &mut |ty, binders| { 530 &mut |ty, binders| {
529 if let Ty::Bound(idx) = &ty { 531 if let Ty::Bound(bound) = &ty {
530 if *idx >= binders as u32 { 532 if bound.index >= num_vars_to_keep && bound.debruijn >= binders {
531 Ty::Unknown 533 Ty::Unknown
532 } else { 534 } else {
533 ty 535 ty
@@ -536,7 +538,7 @@ fn fallback_bound_vars(s: Substs, num_vars_to_keep: usize) -> Substs {
536 ty 538 ty
537 } 539 }
538 }, 540 },
539 num_vars_to_keep, 541 DebruijnIndex::INNERMOST,
540 ) 542 )
541} 543}
542 544
@@ -586,7 +588,7 @@ fn generic_implements_goal(
586 let num_vars = self_ty.num_vars; 588 let num_vars = self_ty.num_vars;
587 let substs = super::Substs::build_for_def(db, trait_) 589 let substs = super::Substs::build_for_def(db, trait_)
588 .push(self_ty.value) 590 .push(self_ty.value)
589 .fill_with_bound_vars(num_vars as u32) 591 .fill_with_bound_vars(DebruijnIndex::INNERMOST, num_vars)
590 .build(); 592 .build();
591 let num_vars = substs.len() - 1 + self_ty.num_vars; 593 let num_vars = substs.len() - 1 + self_ty.num_vars;
592 let trait_ref = TraitRef { trait_, substs }; 594 let trait_ref = TraitRef { trait_, substs };