diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-26 11:16:09 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-26 11:16:49 -0400 |
| commit | 950b40f1119ebe5ae51555ca7d236a899b604a4c (patch) | |
| tree | 825e000b37dcdf62aeb64aa66e23d5ee34974a53 | |
| parent | 519d892f9523fe40cc11ec07323ffc2792614742 (diff) | |
| download | rust-950b40f1119ebe5ae51555ca7d236a899b604a4c.tar.gz rust-950b40f1119ebe5ae51555ca7d236a899b604a4c.zip | |
Don't check match scrutinee of postfix match for unused parens
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 4 | ||||
| -rw-r--r-- | tests/ui/match/postfix-match/no-unused-parens.rs | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 0b757f95a99..111a4fdcea1 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -865,7 +865,9 @@ trait UnusedDelimLint { (iter, UnusedDelimsCtx::ForIterExpr, true, None, Some(body.span.lo()), true) } - Match(ref head, ..) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => { + Match(ref head, _, ast::MatchKind::Prefix) + if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => + { let left = e.span.lo() + rustc_span::BytePos(5); (head, UnusedDelimsCtx::MatchScrutineeExpr, true, Some(left), None, true) } diff --git a/tests/ui/match/postfix-match/no-unused-parens.rs b/tests/ui/match/postfix-match/no-unused-parens.rs new file mode 100644 index 00000000000..46cac7a6107 --- /dev/null +++ b/tests/ui/match/postfix-match/no-unused-parens.rs @@ -0,0 +1,8 @@ +//@ check-pass + +#![feature(postfix_match)] + +fn main() { + (&1).match { a => a }; + (1 + 2).match { b => b }; +} |
