]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/pattern_type_mismatch.rs
Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se
[rust.git] / clippy_lints / src / pattern_type_mismatch.rs
index 4534f6e251659ef2130140abfa7969ef14fad9e7..e7bc24465908b43851b87e2af2483e6ac7758028 100644 (file)
@@ -104,22 +104,25 @@ fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
     }
 
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
-        if let ExprKind::Match(expr, arms, source) = expr.kind {
-            match source {
-                MatchSource::Normal | MatchSource::IfLetDesugar { .. } | MatchSource::WhileLetDesugar => {
-                    if let Some(expr_ty) = cx.typeck_results().node_type_opt(expr.hir_id) {
-                        'pattern_checks: for arm in arms {
-                            let pat = &arm.pat;
-                            if in_external_macro(cx.sess(), pat.span) {
-                                continue 'pattern_checks;
-                            }
-                            if apply_lint(cx, pat, expr_ty, DerefPossible::Possible) {
-                                break 'pattern_checks;
-                            }
-                        }
+        if let ExprKind::Match(scrutinee, arms, MatchSource::Normal) = expr.kind {
+            if let Some(expr_ty) = cx.typeck_results().node_type_opt(scrutinee.hir_id) {
+                'pattern_checks: for arm in arms {
+                    let pat = &arm.pat;
+                    if in_external_macro(cx.sess(), pat.span) {
+                        continue 'pattern_checks;
                     }
-                },
-                _ => (),
+                    if apply_lint(cx, pat, expr_ty, DerefPossible::Possible) {
+                        break 'pattern_checks;
+                    }
+                }
+            }
+        }
+        if let ExprKind::Let(let_pat, let_expr, _) = expr.kind {
+            if let Some(expr_ty) = cx.typeck_results().node_type_opt(let_expr.hir_id) {
+                if in_external_macro(cx.sess(), let_pat.span) {
+                    return;
+                }
+                apply_lint(cx, let_pat, expr_ty, DerefPossible::Possible);
             }
         }
     }