Skip to content

Commit

Permalink
Don't check match scrutinee of postfix match for unused parens
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 26, 2024
1 parent 519d892 commit 950b40f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/match/postfix-match/no-unused-parens.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ check-pass

#![feature(postfix_match)]

fn main() {
(&1).match { a => a };
(1 + 2).match { b => b };
}

0 comments on commit 950b40f

Please sign in to comment.