Supress unused_parens lint for guard patterns
This commit is contained in:
parent
4586feb998
commit
2a3932295e
3 changed files with 16 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,7 +2,7 @@
|
|||
//
|
||||
//@ check-pass
|
||||
#![feature(guard_patterns, never_type)]
|
||||
#![expect(incomplete_features, unused_parens)]
|
||||
#![expect(incomplete_features)]
|
||||
#![deny(unreachable_code)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue