Insert type vars before doing assoc item resolution

This commit is contained in:
Florian Diebold 2019-10-30 21:22:46 +01:00
parent 44279ef1df
commit 7b7133ec58
2 changed files with 15 additions and 12 deletions

View File

@ -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");

View File

@ -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<i32>, i64)
[115; 122) 'S::make': fn make<S<i32>, i64>() -> (Self, T)
[115; 124) 'S::make()': (S<i32>, i64)
"###
);
}
@ -2897,18 +2897,18 @@ struct S<T>;
impl Trait<i64> for S<u64> {}
impl Trait<i32> for S<u32> {}
fn test() {
let a: (Self<i64>, _) = S::make();
let b: (_, u32) = S::make();
let a: (S<u64>, _) = 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<u64>, i64)
[158; 165) 'S::make': fn make<S<u64>, i64>() -> (Self, T)
[158; 167) 'S::make()': (S<u64>, i64)
[177; 178) 'b': (S<u32>, i32)
[191; 198) 'S::make': fn make<S<u32>, i32>() -> (Self, T)
[191; 200) 'S::make()': (S<u32>, i32)
"###
);
}