Skip to content

Commit 69cfe80

Browse files
authored
Rollup merge of #123096 - compiler-errors:postfix-match-parens, r=fmease
Don't check match scrutinee of postfix match for unused parens We only check the scrutinees of block-like constructs and a few others (return/index/assign/method calls). Just don't do it for postfix match at all. Fixes #123064 r? fmease
2 parents 732ded9 + 950b40f commit 69cfe80

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

compiler/rustc_lint/src/unused.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,9 @@ trait UnusedDelimLint {
865865
(iter, UnusedDelimsCtx::ForIterExpr, true, None, Some(body.span.lo()), true)
866866
}
867867

868-
Match(ref head, ..) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
868+
Match(ref head, _, ast::MatchKind::Prefix)
869+
if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX =>
870+
{
869871
let left = e.span.lo() + rustc_span::BytePos(5);
870872
(head, UnusedDelimsCtx::MatchScrutineeExpr, true, Some(left), None, true)
871873
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ check-pass
2+
3+
#![feature(postfix_match)]
4+
5+
fn main() {
6+
(&1).match { a => a };
7+
(1 + 2).match { b => b };
8+
}

0 commit comments

Comments
 (0)