Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ impl UnusedParens {
// `&(a..=b)`, there is a recursive `check_pat` on `a` and `b`, but we will assume
// that if there are unnecessary parens they serve a purpose of readability.
PatKind::Range(..) => return,
// Parentheses may be necessary to disambiguate precedence in guard patterns.
PatKind::Guard(..) => return,
// Avoid `p0 | .. | pn` if we should.
PatKind::Or(..) if avoid_or => return,
// Avoid `mut x` and `mut x @ p` if we should:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Guard patterns require parentheses to disambiguate precedence
//!
//! Regression test for https://github.com/rust-lang/rust/issues/149594

//@ check-pass

#![feature(guard_patterns)]
#![expect(incomplete_features)]
#![warn(unused_parens)]

fn main() {
let (_ if false) = ();
}
2 changes: 1 addition & 1 deletion tests/ui/reachable/guard_read_for_never.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
//@ check-pass
#![feature(guard_patterns, never_type)]
#![expect(incomplete_features, unused_parens)]
#![expect(incomplete_features)]
#![deny(unreachable_code)]

fn main() {
Expand Down
Loading