summaryrefslogtreecommitdiffstats
path: root/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs')
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs152
1 files changed, 0 insertions, 152 deletions
diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
deleted file mode 100644
index 8429799ca..000000000
--- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
+++ /dev/null
@@ -1,152 +0,0 @@
-#![deny(unreachable_patterns)]
-
-// We wrap patterns in a tuple because top-level or-patterns were special-cased.
-fn main() {
- match (0u8,) {
- (1 | 2,) => {}
- (1,) => {} //~ ERROR unreachable pattern
- _ => {}
- }
- match (0u8,) {
- (1 | 2,) => {}
- (2,) => {} //~ ERROR unreachable pattern
- _ => {}
- }
- match (0u8,) {
- (1,) => {}
- (2,) => {}
- (1 | 2,) => {} //~ ERROR unreachable pattern
- _ => {}
- }
- match (0u8, 0u8) {
- (1 | 2, 3 | 4) => {}
- (1, 3) => {} //~ ERROR unreachable pattern
- (1, 4) => {} //~ ERROR unreachable pattern
- (2, 4) => {} //~ ERROR unreachable pattern
- (2 | 1, 4) => {} //~ ERROR unreachable pattern
- (1, 5 | 6) => {}
- (1, 4 | 5) => {} //~ ERROR unreachable pattern
- _ => {}
- }
- match (true, true) {
- (false | true, false | true) => (),
- }
- match (Some(0u8),) {
- (None | Some(1 | 2),) => {}
- (Some(1),) => {} //~ ERROR unreachable pattern
- (None,) => {} //~ ERROR unreachable pattern
- _ => {}
- }
- match ((0u8,),) {
- ((1 | 2,) | (3 | 4,),) => {}
- ((1..=4,),) => {} //~ ERROR unreachable pattern
- _ => {}
- }
-
- match (0,) {
- (1 | 1,) => {} //~ ERROR unreachable
- _ => {}
- }
- match 0 {
- (0 | 1) | 1 => {} //~ ERROR unreachable
- _ => {}
- }
- match 0 {
- // We get two errors because recursive or-pattern expansion means we don't notice the two
- // errors span a whole pattern. This could be better but doesn't matter much
- 0 | (0 | 0) => {}
- //~^ ERROR unreachable
- //~| ERROR unreachable
- _ => {}
- }
- match None {
- // There is only one error that correctly points to the whole subpattern
- Some(0) |
- Some( //~ ERROR unreachable
- 0 | 0) => {}
- _ => {}
- }
- match [0; 2] {
- [0
- | 0 //~ ERROR unreachable
- , 0
- | 0] => {} //~ ERROR unreachable
- _ => {}
- }
- match &[][..] {
- [0] => {}
- [0, _] => {}
- [0, _, _] => {}
- [1, ..] => {}
- [1 //~ ERROR unreachable
- | 2, ..] => {}
- _ => {}
- }
- match &[][..] {
- [true] => {}
- [true | false, ..] => {}
- _ => {}
- }
- match &[][..] {
- [false] => {}
- [true, ..] => {}
- [true //~ ERROR unreachable
- | false, ..] => {}
- _ => {}
- }
- match (true, None) {
- (true, Some(_)) => {}
- (false, Some(true)) => {}
- (true | false, None | Some(true //~ ERROR unreachable
- | false)) => {}
- }
- macro_rules! t_or_f {
- () => {
- (true //~ ERROR unreachable
- | false)
- };
- }
- match (true, None) {
- (true, Some(_)) => {}
- (false, Some(true)) => {}
- (true | false, None | Some(t_or_f!())) => {}
- }
- match Some(0) {
- Some(0) => {}
- Some(0 //~ ERROR unreachable
- | 1) => {}
- _ => {}
- }
-
- // A subpattern that is only unreachable in one branch is overall reachable.
- match (true, true) {
- (true, true) => {}
- (false | true, false | true) => {}
- }
- match (true, true) {
- (true, true) => {}
- (false, false) => {}
- (false | true, false | true) => {}
- }
- // https://github.com/rust-lang/rust/issues/76836
- match None {
- Some(false) => {}
- None | Some(true
- | false) => {} //~ ERROR unreachable
- }
-
- // A subpattern that is unreachable in all branches is overall unreachable.
- match (true, true) {
- (false, true) => {}
- (true, true) => {}
- (false | true, false
- | true) => {} //~ ERROR unreachable
- }
- match (true, true) {
- (true, false) => {}
- (true, true) => {}
- (false
- | true, //~ ERROR unreachable
- false | true) => {}
- }
-}