aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/expr.rs
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2020-04-11 04:14:53 +0100
committerJosh Mcguigan <[email protected]>2020-04-11 04:14:53 +0100
commitd1338354ca7afae7088f84756ed103ea94ce82f9 (patch)
tree750a1e7323380d9112ba0a64c9f8a5fff3cf3a13 /crates/ra_hir_ty/src/expr.rs
parentbeb755caa2b1d7265da7d3367af3b49039dfe00e (diff)
fix match arm false positive
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r--crates/ra_hir_ty/src/expr.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs
index 827b687de..03ef488b9 100644
--- a/crates/ra_hir_ty/src/expr.rs
+++ b/crates/ra_hir_ty/src/expr.rs
@@ -163,12 +163,6 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
163 163
164 let mut seen = Matrix::empty(); 164 let mut seen = Matrix::empty();
165 for pat in pats { 165 for pat in pats {
166 // We skip any patterns whose type we cannot resolve.
167 //
168 // This could lead to false positives in this diagnostic, so
169 // it might be better to skip the entire diagnostic if we either
170 // cannot resolve a match arm or determine that the match arm has
171 // the wrong type.
172 if let Some(pat_ty) = infer.type_of_pat.get(pat) { 166 if let Some(pat_ty) = infer.type_of_pat.get(pat) {
173 // We only include patterns whose type matches the type 167 // We only include patterns whose type matches the type
174 // of the match expression. If we had a InvalidMatchArmPattern 168 // of the match expression. If we had a InvalidMatchArmPattern
@@ -191,8 +185,15 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
191 // to the matrix here. 185 // to the matrix here.
192 let v = PatStack::from_pattern(pat); 186 let v = PatStack::from_pattern(pat);
193 seen.push(&cx, v); 187 seen.push(&cx, v);
188 continue;
194 } 189 }
195 } 190 }
191
192 // If we can't resolve the type of a pattern, or the pattern type doesn't
193 // fit the match expression, we skip this diagnostic. Skipping the entire
194 // diagnostic rather than just not including this match arm is preferred
195 // to avoid the chance of false positives.
196 return;
196 } 197 }
197 198
198 match is_useful(&cx, &seen, &PatStack::from_wild()) { 199 match is_useful(&cx, &seen, &PatStack::from_wild()) {