}
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);
}
}
}