Fix false positive "Missing match arm".

This commit is contained in:
Dawer 2021-05-15 00:09:17 +05:00
parent 6c0f20d79f
commit 2abb4c99fe
3 changed files with 7 additions and 5 deletions

View File

@ -1119,6 +1119,7 @@ fn main() {
(true, false, true) => (),
(true) => (),
}
match (true, false) { (true,) => {} }
match (0) { () => () }
match Unresolved::Bar { Unresolved::Baz => () }
}

View File

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

View File

@ -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*/}': ()