aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/method_resolution.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-04-09 21:04:59 +0100
committerFlorian Diebold <[email protected]>2019-04-14 10:28:53 +0100
commit9339241b78ef7474e88de37738bdbece7767d333 (patch)
treec253d26db406b0f6cac5db67a054f4334b016486 /crates/ra_hir/src/ty/method_resolution.rs
parenta1ed53a4f183b5826162eb9e998207b92be9c57f (diff)
Some cleanup
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs13
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.
236fn fresh_substs_for_trait(db: &impl HirDatabase, tr: Trait, self_ty: Ty) -> Substs { 240fn 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}