Merge #8840
8840: fix: false positive "Missing match arm" when a tuple pattern is shorter than scrutinee type. r=Veykril a=iDawer ![Screenshot_20210515_003035](https://user-images.githubusercontent.com/7803845/118320023-2bcb7380-b4eb-11eb-9de6-d8762f981dc2.jpg) Match checking diagnostic shouldn't fire when there is type mismatches. rust-analyzer fd109fb58 2021-05-10 dev (This is part of the preparation for https://github.com/rust-analyzer/rust-analyzer/pull/8717) Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
This commit is contained in:
commit
e5e6c363dc
@ -1119,6 +1119,7 @@ fn main() {
|
||||
(true, false, true) => (),
|
||||
(true) => (),
|
||||
}
|
||||
match (true, false) { (true,) => {} }
|
||||
match (0) { () => () }
|
||||
match Unresolved::Bar { Unresolved::Baz => () }
|
||||
}
|
||||
|
@ -126,11 +126,12 @@ impl<'a> InferenceContext<'a> {
|
||||
_ => &[],
|
||||
};
|
||||
|
||||
let (pre, post) = match ellipsis {
|
||||
Some(idx) => args.split_at(idx),
|
||||
None => (&args[..], &[][..]),
|
||||
let ((pre, post), n_uncovered_patterns) = match ellipsis {
|
||||
Some(idx) => {
|
||||
(args.split_at(idx), expectations.len().saturating_sub(args.len()))
|
||||
}
|
||||
None => ((&args[..], &[][..]), 0),
|
||||
};
|
||||
let n_uncovered_patterns = expectations.len().saturating_sub(args.len());
|
||||
let err_ty = self.err_ty();
|
||||
let mut expectations_iter =
|
||||
expectations.iter().map(|a| a.assert_ty_ref(&Interner)).chain(repeat(&err_ty));
|
||||
|
@ -732,7 +732,7 @@ fn foo(tuple: (u8, i16, f32)) {
|
||||
111..112 'a': u8
|
||||
114..115 'b': i16
|
||||
124..126 '{}': ()
|
||||
136..142 '(a, b)': (u8, i16, f32)
|
||||
136..142 '(a, b)': (u8, i16)
|
||||
137..138 'a': u8
|
||||
140..141 'b': i16
|
||||
146..161 '{/*too short*/}': ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user