diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-14 20:57:52 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-14 20:57:52 +0100 |
commit | e5e6c363dc7ef081d6c9a5377563d3632c579ab2 (patch) | |
tree | 0855e13268d9b2d8cae15fe7ba1ffca05dee59b1 /crates/hir_ty/src/infer | |
parent | 260bcd942b9e6b13aa2d3257a08157bb8544b726 (diff) | |
parent | 2abb4c99fe8a5839fe2910e90f3471e6308f6229 (diff) |
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 <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index aea354cde..60b94a642 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -126,11 +126,12 @@ impl<'a> InferenceContext<'a> { | |||
126 | _ => &[], | 126 | _ => &[], |
127 | }; | 127 | }; |
128 | 128 | ||
129 | let (pre, post) = match ellipsis { | 129 | let ((pre, post), n_uncovered_patterns) = match ellipsis { |
130 | Some(idx) => args.split_at(idx), | 130 | Some(idx) => { |
131 | None => (&args[..], &[][..]), | 131 | (args.split_at(idx), expectations.len().saturating_sub(args.len())) |
132 | } | ||
133 | None => ((&args[..], &[][..]), 0), | ||
132 | }; | 134 | }; |
133 | let n_uncovered_patterns = expectations.len().saturating_sub(args.len()); | ||
134 | let err_ty = self.err_ty(); | 135 | let err_ty = self.err_ty(); |
135 | let mut expectations_iter = | 136 | let mut expectations_iter = |
136 | expectations.iter().map(|a| a.assert_ty_ref(&Interner)).chain(repeat(&err_ty)); | 137 | expectations.iter().map(|a| a.assert_ty_ref(&Interner)).chain(repeat(&err_ty)); |