diff options
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/expr.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 8c7d1a98e..6efed6f9e 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs | |||
@@ -93,7 +93,16 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
93 | // of the match expression. If we had a InvalidMatchArmPattern | 93 | // of the match expression. If we had a InvalidMatchArmPattern |
94 | // diagnostic or similar we could raise that in an else | 94 | // diagnostic or similar we could raise that in an else |
95 | // block here. | 95 | // block here. |
96 | if pat_ty == match_expr_ty { | 96 | // |
97 | // When comparing the types, we also have to consider that rustc | ||
98 | // will automatically de-reference the match expression type if | ||
99 | // necessary. | ||
100 | if pat_ty == match_expr_ty | ||
101 | || match_expr_ty | ||
102 | .as_reference() | ||
103 | .map(|(match_expr_ty, _)| match_expr_ty == pat_ty) | ||
104 | .unwrap_or(false) | ||
105 | { | ||
97 | // If we had a NotUsefulMatchArm diagnostic, we could | 106 | // If we had a NotUsefulMatchArm diagnostic, we could |
98 | // check the usefulness of each pattern as we added it | 107 | // check the usefulness of each pattern as we added it |
99 | // to the matrix here. | 108 | // to the matrix here. |