diff options
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index f69b8304b..126edeaff 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -233,15 +233,16 @@ impl Ty { | |||
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | /// This creates Substs for a trait with the given Self type and type variables | ||
237 | /// for all other parameters. This is kind of a hack since these aren't 'real' | ||
238 | /// type variables; the resulting trait reference is just used for the | ||
239 | /// preliminary method candidate check. | ||
236 | fn fresh_substs_for_trait(db: &impl HirDatabase, tr: Trait, self_ty: Ty) -> Substs { | 240 | fn fresh_substs_for_trait(db: &impl HirDatabase, tr: Trait, self_ty: Ty) -> Substs { |
237 | let mut substs = Vec::new(); | 241 | let mut substs = Vec::new(); |
238 | let mut counter = 0; | ||
239 | let generics = tr.generic_params(db); | 242 | let generics = tr.generic_params(db); |
240 | substs.push(self_ty); | 243 | substs.push(self_ty); |
241 | substs.extend(generics.params_including_parent().into_iter().skip(1).map(|_p| { | 244 | substs.extend(generics.params_including_parent().into_iter().skip(1).enumerate().map( |
242 | let fresh_var = Ty::Infer(super::infer::InferTy::TypeVar(super::infer::TypeVarId(counter))); | 245 | |(i, _p)| Ty::Infer(super::infer::InferTy::TypeVar(super::infer::TypeVarId(i as u32))), |
243 | counter += 1; | 246 | )); |
244 | fresh_var | ||
245 | })); | ||
246 | substs.into() | 247 | substs.into() |
247 | } | 248 | } |