From 7b7133ec58818894d3d56df021ae70159e2c3252 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 30 Oct 2019 21:22:46 +0100 Subject: Insert type vars before doing assoc item resolution --- crates/ra_hir/src/ty/infer/path.rs | 3 +++ crates/ra_hir/src/ty/tests.rs | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs index 885588174..0cde77265 100644 --- a/crates/ra_hir/src/ty/infer/path.rs +++ b/crates/ra_hir/src/ty/infer/path.rs @@ -124,6 +124,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { return None; } + let ty = self.insert_type_vars(ty); + let ty = self.normalize_associated_types_in(ty); + let segment = remaining_segments.last().expect("there should be at least one segment here"); diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 3af926279..e071e4d4e 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -2879,9 +2879,9 @@ fn test() { "#), @r###" [101; 127) '{ ...e(); }': () - [111; 112) 'a': {unknown} - [115; 122) 'S::make': {unknown} - [115; 124) 'S::make()': {unknown} + [111; 112) 'a': (S, i64) + [115; 122) 'S::make': fn make, i64>() -> (Self, T) + [115; 124) 'S::make()': (S, i64) "### ); } @@ -2897,18 +2897,18 @@ struct S; impl Trait for S {} impl Trait for S {} fn test() { - let a: (Self, _) = S::make(); - let b: (_, u32) = S::make(); + let a: (S, _) = S::make(); + let b: (_, i32) = S::make(); } "#), @r###" - [131; 206) '{ ...e(); }': () - [141; 142) 'a': ({unknown}, {unknown}) - [161; 168) 'S::make': {unknown} - [161; 170) 'S::make()': ({unknown}, {unknown}) - [180; 181) 'b': ({unknown}, u32) - [194; 201) 'S::make': {unknown} - [194; 203) 'S::make()': ({unknown}, u32) + [131; 203) '{ ...e(); }': () + [141; 142) 'a': (S, i64) + [158; 165) 'S::make': fn make, i64>() -> (Self, T) + [158; 167) 'S::make()': (S, i64) + [177; 178) 'b': (S, i32) + [191; 198) 'S::make': fn make, i32>() -> (Self, T) + [191; 200) 'S::make()': (S, i32) "### ); } -- cgit v1.2.3