mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Normalize all types when finishing inference
The new solver does not eagerly normalize, but things after inference expect types to be normalized. rustc does the same. Also, I'm afraid other things in r-a don't expect results of the solver to be unnormalized. We'll need to handle that.
This commit is contained in:
parent
58a7de6c4d
commit
1ff80eefe1
@ -621,6 +621,9 @@ impl<'a> InferenceTable<'a> {
|
||||
where
|
||||
T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
|
||||
{
|
||||
let t = self.resolve_with_fallback(t, &|_, _, d, _| d);
|
||||
let t = self.normalize_associated_types_in(t);
|
||||
// Resolve again, because maybe normalization inserted infer vars.
|
||||
self.resolve_with_fallback(t, &|_, _, d, _| d)
|
||||
}
|
||||
|
||||
|
@ -24,3 +24,29 @@ impl<'a> IntoIterator for &'a Grid {
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalization() {
|
||||
check_infer(
|
||||
r#"
|
||||
//- minicore: iterator, iterators
|
||||
fn main() {
|
||||
_ = [0i32].into_iter().filter_map(|_n| Some(1i32));
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
10..69 '{ ...2)); }': ()
|
||||
16..17 '_': FilterMap<IntoIter<i32, 1>, impl FnMut(i32) -> Option<i32>>
|
||||
16..66 '_ = [0...1i32))': ()
|
||||
20..26 '[0i32]': [i32; 1]
|
||||
20..38 '[0i32]...iter()': IntoIter<i32, 1>
|
||||
20..66 '[0i32]...1i32))': FilterMap<IntoIter<i32, 1>, impl FnMut(i32) -> Option<i32>>
|
||||
21..25 '0i32': i32
|
||||
50..65 '|_n| Some(1i32)': impl FnMut(i32) -> Option<i32>
|
||||
51..53 '_n': i32
|
||||
55..59 'Some': fn Some<i32>(i32) -> Option<i32>
|
||||
55..65 'Some(1i32)': Option<i32>
|
||||
60..64 '1i32': i32
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user