mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 11:17:26 +03:00
f049a64100
The pretty printer now correctly parenthesizes or-patterns inside `box` patterns, which changes the Clippy `unnested_or_patterns` lint suggestion from `box box (0 | 2 | 4)` to `box (box (0 | 2 | 4))`. The new output is more correct — the old suggestion was itself missing parens and would have been parsed as `box (box 0) | 2 | 4`. Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
29 lines
887 B
Rust
29 lines
887 B
Rust
#![feature(box_patterns)]
|
|
#![warn(clippy::unnested_or_patterns)]
|
|
#![allow(
|
|
clippy::cognitive_complexity,
|
|
clippy::match_ref_pats,
|
|
clippy::needless_ifs,
|
|
clippy::manual_range_patterns
|
|
)]
|
|
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
|
|
|
|
fn main() {
|
|
if let Some(Some(0 | 1)) = None {}
|
|
//~^ unnested_or_patterns
|
|
if let Some(Some(0 | 1 | 2)) = None {}
|
|
//~^ unnested_or_patterns
|
|
if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
|
|
//~^ unnested_or_patterns
|
|
if let Some(Some(0 | 1 | 2)) = None {}
|
|
//~^ unnested_or_patterns
|
|
if let ((0 | 1 | 2,),) = ((0,),) {}
|
|
//~^ unnested_or_patterns
|
|
if let 0 | 1 | 2 = 0 {}
|
|
//~^ unnested_or_patterns
|
|
if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
|
|
//~^ unnested_or_patterns
|
|
if let box (box (0 | 2 | 4)) = Box::new(Box::new(0)) {}
|
|
//~^ unnested_or_patterns
|
|
}
|