about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-04 22:25:02 +0200
committerGitHub <noreply@github.com>2022-08-04 22:25:02 +0200
commit6b938c8491bc8d16a9a1a4d080368485f4454d31 (patch)
tree3b64e51f9b87427d80439f52038e85cecaf74fce /compiler/rustc_lint/src
parentd3aa757ff8244f83a7dfe4995fe5d2da78399252 (diff)
parent8dd44f1af4ac49331d0998eebae21d54b0ab5bde (diff)
downloadrust-6b938c8491bc8d16a9a1a4d080368485f4454d31.tar.gz
rust-6b938c8491bc8d16a9a1a4d080368485f4454d31.zip
Rollup merge of #100093 - wcampbell0x2a:unused-parens-for-match-arms, r=petrochenkov
Enable unused_parens for match arms

Fixes: https://github.com/rust-lang/rust/issues/92751

Currently I can't get the `stderr` to work with `./x.py test`, but this should fix the issue. Help would be appreciated!
Diffstat (limited to 'compiler/rustc_lint/src')
-rw-r--r--compiler/rustc_lint/src/unused.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index 53269d18527..b6cf182916c 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -396,6 +396,7 @@ enum UnusedDelimsCtx {
     LetScrutineeExpr,
     ArrayLenExpr,
     AnonConst,
+    MatchArmExpr,
 }
 
 impl From<UnusedDelimsCtx> for &'static str {
@@ -414,6 +415,7 @@ impl From<UnusedDelimsCtx> for &'static str {
             UnusedDelimsCtx::BlockRetValue => "block return value",
             UnusedDelimsCtx::LetScrutineeExpr => "`let` scrutinee expression",
             UnusedDelimsCtx::ArrayLenExpr | UnusedDelimsCtx::AnonConst => "const expression",
+            UnusedDelimsCtx::MatchArmExpr => "match arm expression",
         }
     }
 }
@@ -805,6 +807,18 @@ impl EarlyLintPass for UnusedParens {
                 }
                 return;
             }
+            ExprKind::Match(ref _expr, ref arm) => {
+                for a in arm {
+                    self.check_unused_delims_expr(
+                        cx,
+                        &a.body,
+                        UnusedDelimsCtx::MatchArmExpr,
+                        false,
+                        None,
+                        None,
+                    );
+                }
+            }
             _ => {}
         }