aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/lower.rs23
-rw-r--r--crates/ra_hir/src/ty/tests.rs12
2 files changed, 10 insertions, 25 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 35fdd4a37..a83842b0f 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -189,26 +189,11 @@ impl Ty {
189 } 189 }
190 190
191 fn select_associated_type( 191 fn select_associated_type(
192 db: &impl HirDatabase, 192 _db: &impl HirDatabase,
193 resolver: &Resolver, 193 _resolver: &Resolver,
194 self_ty: Ty, 194 _self_ty: Ty,
195 segment: &PathSegment, 195 _segment: &PathSegment,
196 ) -> Ty { 196 ) -> Ty {
197 let env = trait_env(db, resolver);
198 let traits_from_env = env.trait_predicates_for_self_ty(&self_ty).map(|tr| tr.trait_);
199 let traits = traits_from_env.flat_map(|t| t.all_super_traits(db));
200 for t in traits {
201 if let Some(associated_ty) = t.associated_type_by_name(db, &segment.name) {
202 let generics = t.generic_params(db);
203 let mut substs = Vec::new();
204 substs.push(self_ty.clone());
205 substs.extend(
206 iter::repeat(Ty::Unknown).take(generics.count_params_including_parent() - 1),
207 );
208 // FIXME handle type parameters on the segment
209 return Ty::Projection(ProjectionTy { associated_ty, parameters: substs.into() });
210 }
211 }
212 Ty::Unknown 197 Ty::Unknown
213 } 198 }
214 199
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 9a3faa9ab..09c17fdf4 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2740,17 +2740,17 @@ fn test() {
2740 [202; 203) 't': T 2740 [202; 203) 't': T
2741 [221; 223) '{}': () 2741 [221; 223) '{}': ()
2742 [234; 300) '{ ...(S); }': () 2742 [234; 300) '{ ...(S); }': ()
2743 [244; 245) 'x': u32 2743 [244; 245) 'x': {unknown}
2744 [248; 252) 'foo1': fn foo1<S>(T) -> <T as Iterable>::Item 2744 [248; 252) 'foo1': fn foo1<S>(T) -> {unknown}
2745 [248; 255) 'foo1(S)': u32 2745 [248; 255) 'foo1(S)': {unknown}
2746 [253; 254) 'S': S 2746 [253; 254) 'S': S
2747 [265; 266) 'y': u32 2747 [265; 266) 'y': u32
2748 [269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item 2748 [269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
2749 [269; 276) 'foo2(S)': u32 2749 [269; 276) 'foo2(S)': u32
2750 [274; 275) 'S': S 2750 [274; 275) 'S': S
2751 [286; 287) 'z': u32 2751 [286; 287) 'z': {unknown}
2752 [290; 294) 'foo3': fn foo3<S>(T) -> <T as Iterable>::Item 2752 [290; 294) 'foo3': fn foo3<S>(T) -> {unknown}
2753 [290; 297) 'foo3(S)': u32 2753 [290; 297) 'foo3(S)': {unknown}
2754 [295; 296) 'S': S 2754 [295; 296) 'S': S
2755 "### 2755 "###
2756 ); 2756 );