Skip to content

Commit

Permalink
split unnested_or_patterns test
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Mar 29, 2020
1 parent 8a0c6c3 commit 46aa951
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 105 deletions.
8 changes: 0 additions & 8 deletions tests/ui/unnested_or_patterns.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,4 @@ fn main() {
}
if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {}
if let S { x: 0, y, .. } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
if let Some(Some(0 | 1)) = None {}
if let Some(Some(0 | 1 | 2)) = None {}
if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
if let Some(Some(0 | 1 | 2)) = None {}
if let ((0 | 1 | 2,),) = ((0,),) {}
if let 0 | 1 | 2 = 0 {}
if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
if let box box (0 | 2 | 4) = Box::new(Box::new(0)) {}
}
8 changes: 0 additions & 8 deletions tests/ui/unnested_or_patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,4 @@ fn main() {
}
if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
if let S { x: 0, y, .. } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
if let Some(Some(0)) | Some(Some(1)) = None {}
if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {}
if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {}
if let Some(Some(0) | Some(1 | 2)) = None {}
if let ((0,),) | ((1,) | (2,),) = ((0,),) {}
if let 0 | (1 | 2) = 0 {}
if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {}
if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {}
}
90 changes: 1 addition & 89 deletions tests/ui/unnested_or_patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -175,93 +175,5 @@ help: nest the patterns
LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {}
| ^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:33:12
|
LL | if let Some(Some(0)) | Some(Some(1)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1)) = None {}
| ^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:34:12
|
LL | if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:35:12
|
LL | if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:36:12
|
LL | if let Some(Some(0) | Some(1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:37:12
|
LL | if let ((0,),) | ((1,) | (2,),) = ((0,),) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let ((0 | 1 | 2,),) = ((0,),) {}
| ^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:38:12
|
LL | if let 0 | (1 | 2) = 0 {}
| ^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let 0 | 1 | 2 = 0 {}
| ^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:39:12
|
LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
| ^^^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns.rs:40:12
|
LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let box box (0 | 2 | 4) = Box::new(Box::new(0)) {}
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 24 previous errors
error: aborting due to 16 previous errors

18 changes: 18 additions & 0 deletions tests/ui/unnested_or_patterns2.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// run-rustfix

#![feature(or_patterns)]
#![feature(box_patterns)]
#![warn(clippy::unnested_or_patterns)]
#![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]

fn main() {
if let Some(Some(0 | 1)) = None {}
if let Some(Some(0 | 1 | 2)) = None {}
if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
if let Some(Some(0 | 1 | 2)) = None {}
if let ((0 | 1 | 2,),) = ((0,),) {}
if let 0 | 1 | 2 = 0 {}
if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
if let box box (0 | 2 | 4) = Box::new(Box::new(0)) {}
}
18 changes: 18 additions & 0 deletions tests/ui/unnested_or_patterns2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// run-rustfix

#![feature(or_patterns)]
#![feature(box_patterns)]
#![warn(clippy::unnested_or_patterns)]
#![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]

fn main() {
if let Some(Some(0)) | Some(Some(1)) = None {}
if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {}
if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {}
if let Some(Some(0) | Some(1 | 2)) = None {}
if let ((0,),) | ((1,) | (2,),) = ((0,),) {}
if let 0 | (1 | 2) = 0 {}
if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {}
if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {}
}
91 changes: 91 additions & 0 deletions tests/ui/unnested_or_patterns2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:10:12
|
LL | if let Some(Some(0)) | Some(Some(1)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::unnested-or-patterns` implied by `-D warnings`
help: nest the patterns
|
LL | if let Some(Some(0 | 1)) = None {}
| ^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:11:12
|
LL | if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:12:12
|
LL | if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:13:12
|
LL | if let Some(Some(0) | Some(1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let Some(Some(0 | 1 | 2)) = None {}
| ^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:14:12
|
LL | if let ((0,),) | ((1,) | (2,),) = ((0,),) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let ((0 | 1 | 2,),) = ((0,),) {}
| ^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:15:12
|
LL | if let 0 | (1 | 2) = 0 {}
| ^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let 0 | 1 | 2 = 0 {}
| ^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:16:12
|
LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
| ^^^^^^^^^^^^^^^^^^^^^^^

error: unnested or-patterns
--> $DIR/unnested_or_patterns2.rs:17:12
|
LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: nest the patterns
|
LL | if let box box (0 | 2 | 4) = Box::new(Box::new(0)) {}
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors

0 comments on commit 46aa951

Please sign in to comment.