From 9339241b78ef7474e88de37738bdbece7767d333 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 9 Apr 2019 22:04:59 +0200 Subject: Some cleanup --- crates/ra_hir/src/ty/method_resolution.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/ty/method_resolution.rs') 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 { } } +/// This creates Substs for a trait with the given Self type and type variables +/// for all other parameters. This is kind of a hack since these aren't 'real' +/// type variables; the resulting trait reference is just used for the +/// preliminary method candidate check. fn fresh_substs_for_trait(db: &impl HirDatabase, tr: Trait, self_ty: Ty) -> Substs { let mut substs = Vec::new(); - let mut counter = 0; let generics = tr.generic_params(db); substs.push(self_ty); - substs.extend(generics.params_including_parent().into_iter().skip(1).map(|_p| { - let fresh_var = Ty::Infer(super::infer::InferTy::TypeVar(super::infer::TypeVarId(counter))); - counter += 1; - fresh_var - })); + substs.extend(generics.params_including_parent().into_iter().skip(1).enumerate().map( + |(i, _p)| Ty::Infer(super::infer::InferTy::TypeVar(super::infer::TypeVarId(i as u32))), + )); substs.into() } -- cgit v1.2.3