Enable unused_parens for match arms

This commit is contained in:
wcampbell 2022-08-03 00:00:04 -04:00
parent c9e134e1b6
commit 8dd44f1af4
6 changed files with 58 additions and 3 deletions

View file

@ -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,
);
}
}
_ => {}
}