aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/expr.rs
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2020-04-07 13:17:59 +0100
committerJosh Mcguigan <[email protected]>2020-04-07 13:17:59 +0100
commit9fc1f51b7ade2cda7d410450ab1347311eb074af (patch)
treef25e0db350072cf8d084ce81adcaeeeaac3f4c42 /crates/ra_hir_ty/src/expr.rs
parenta208de15b7846911856e6c069f7df03676c18a03 (diff)
add fixme to use type checker rather than manually comparing types
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r--crates/ra_hir_ty/src/expr.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs
index 19323fda1..1e7395b16 100644
--- a/crates/ra_hir_ty/src/expr.rs
+++ b/crates/ra_hir_ty/src/expr.rs
@@ -88,6 +88,11 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
88 let mut seen = Matrix::empty(); 88 let mut seen = Matrix::empty();
89 for pat in pats { 89 for pat in pats {
90 // We skip any patterns whose type we cannot resolve. 90 // We skip any patterns whose type we cannot resolve.
91 //
92 // This could lead to false positives in this diagnostic, so
93 // it might be better to skip the entire diagnostic if we either
94 // cannot resolve a match arm or determine that the match arm has
95 // the wrong type.
91 if let Some(pat_ty) = infer.type_of_pat.get(pat) { 96 if let Some(pat_ty) = infer.type_of_pat.get(pat) {
92 // We only include patterns whose type matches the type 97 // We only include patterns whose type matches the type
93 // of the match expression. If we had a InvalidMatchArmPattern 98 // of the match expression. If we had a InvalidMatchArmPattern
@@ -97,6 +102,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
97 // When comparing the types, we also have to consider that rustc 102 // When comparing the types, we also have to consider that rustc
98 // will automatically de-reference the match expression type if 103 // will automatically de-reference the match expression type if
99 // necessary. 104 // necessary.
105 //
106 // FIXME we should use the type checker for this.
100 if pat_ty == match_expr_ty 107 if pat_ty == match_expr_ty
101 || match_expr_ty 108 || match_expr_ty
102 .as_reference() 109 .as_reference()