summaryrefslogtreecommitdiffstats
path: root/tests/ui/or-patterns
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/or-patterns
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/or-patterns')
-rw-r--r--tests/ui/or-patterns/exhaustiveness-pass.rs11
-rw-r--r--tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs10
-rw-r--r--tests/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr72
-rw-r--r--tests/ui/or-patterns/fn-param-wrap-parens.stderr2
-rw-r--r--tests/ui/or-patterns/inconsistent-modes.stderr4
-rw-r--r--tests/ui/or-patterns/inner-or-pat.or3.stderr2
-rw-r--r--tests/ui/or-patterns/inner-or-pat.or4.stderr2
-rw-r--r--tests/ui/or-patterns/while-parsing-this-or-pattern.stderr2
8 files changed, 72 insertions, 33 deletions
diff --git a/tests/ui/or-patterns/exhaustiveness-pass.rs b/tests/ui/or-patterns/exhaustiveness-pass.rs
index 428b9a19f..a52e08c50 100644
--- a/tests/ui/or-patterns/exhaustiveness-pass.rs
+++ b/tests/ui/or-patterns/exhaustiveness-pass.rs
@@ -35,6 +35,17 @@ fn main() {
((0, 0) | (1, 0),) => {}
_ => {}
}
+ match ((0, 0),) {
+ // Note how the second one would be redundant without the guard.
+ ((x, y) | (y, x),) if x == 0 => {}
+ _ => {}
+ }
+ match 0 {
+ // We don't warn the second one as redundant in general because of cases like the one above.
+ // We could technically do it if there are no bindings.
+ 0 | 0 if 0 == 0 => {}
+ _ => {}
+ }
// This one caused ICE https://github.com/rust-lang/rust/issues/117378
match (0u8, 0) {
diff --git a/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
index 8429799ca..20a8d7549 100644
--- a/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
+++ b/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
@@ -1,6 +1,7 @@
#![deny(unreachable_patterns)]
// We wrap patterns in a tuple because top-level or-patterns were special-cased.
+#[rustfmt::skip]
fn main() {
match (0u8,) {
(1 | 2,) => {}
@@ -73,6 +74,11 @@ fn main() {
| 0] => {} //~ ERROR unreachable
_ => {}
}
+ match (true, 0) {
+ (true, 0 | 0) => {} //~ ERROR unreachable
+ (_, 0 | 0) => {} //~ ERROR unreachable
+ _ => {}
+ }
match &[][..] {
[0] => {}
[0, _] => {}
@@ -149,4 +155,8 @@ fn main() {
| true, //~ ERROR unreachable
false | true) => {}
}
+ match (true, true) {
+ (x, y)
+ | (y, x) => {} //~ ERROR unreachable
+ }
}
diff --git a/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
index 3f7d47dcb..3616dda99 100644
--- a/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
+++ b/tests/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
@@ -1,5 +1,5 @@
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:7:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:8:9
|
LL | (1,) => {}
| ^^^^
@@ -11,128 +11,140 @@ LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:12:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:13:9
|
LL | (2,) => {}
| ^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:18:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:19:9
|
LL | (1 | 2,) => {}
| ^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:23:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
|
LL | (1, 3) => {}
| ^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
|
LL | (1, 4) => {}
| ^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
|
LL | (2, 4) => {}
| ^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:27:9
|
LL | (2 | 1, 4) => {}
| ^^^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:28:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:29:9
|
LL | (1, 4 | 5) => {}
| ^^^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:36:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
|
LL | (Some(1),) => {}
| ^^^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:37:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:38:9
|
LL | (None,) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:42:9
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:43:9
|
LL | ((1..=4,),) => {}
| ^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:47:14
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:48:14
|
LL | (1 | 1,) => {}
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:51:19
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:52:19
|
LL | (0 | 1) | 1 => {}
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:57:14
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:58:14
|
LL | 0 | (0 | 0) => {}
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:57:18
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:58:18
|
LL | 0 | (0 | 0) => {}
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:65:13
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:66:13
|
LL | / Some(
LL | | 0 | 0) => {}
| |______________________^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:71:15
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:72:15
|
LL | | 0
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:73:15
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:74:15
|
LL | | 0] => {}
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:81:10
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:78:20
+ |
+LL | (true, 0 | 0) => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:79:17
+ |
+LL | (_, 0 | 0) => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:87:10
|
LL | [1
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:93:10
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:99:10
|
LL | [true
| ^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:100:36
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:106:36
|
LL | (true | false, None | Some(true
| ^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:105:14
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:111:14
|
LL | (true
| ^^^^
@@ -143,28 +155,34 @@ LL | (true | false, None | Some(t_or_f!())) => {}
= note: this error originates in the macro `t_or_f` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:116:14
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:122:14
|
LL | Some(0
| ^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:135:19
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:141:19
|
LL | | false) => {}
| ^^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:143:15
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:149:15
|
LL | | true) => {}
| ^^^^
error: unreachable pattern
- --> $DIR/exhaustiveness-unreachable-pattern.rs:149:15
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:155:15
|
LL | | true,
| ^^^^
-error: aborting due to 26 previous errors
+error: unreachable pattern
+ --> $DIR/exhaustiveness-unreachable-pattern.rs:160:15
+ |
+LL | | (y, x) => {}
+ | ^^^^^^
+
+error: aborting due to 29 previous errors
diff --git a/tests/ui/or-patterns/fn-param-wrap-parens.stderr b/tests/ui/or-patterns/fn-param-wrap-parens.stderr
index 732702841..1b9614a13 100644
--- a/tests/ui/or-patterns/fn-param-wrap-parens.stderr
+++ b/tests/ui/or-patterns/fn-param-wrap-parens.stderr
@@ -4,5 +4,5 @@ error: top-level or-patterns are not allowed in function parameters
LL | fn fun1(A | B: E) {}
| ^^^^^ help: wrap the pattern in parentheses: `(A | B)`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/or-patterns/inconsistent-modes.stderr b/tests/ui/or-patterns/inconsistent-modes.stderr
index f6367ef82..19618d336 100644
--- a/tests/ui/or-patterns/inconsistent-modes.stderr
+++ b/tests/ui/or-patterns/inconsistent-modes.stderr
@@ -57,8 +57,8 @@ LL | let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
| | types differ in mutability
| first introduced with type `&&u8` here
|
- = note: expected reference `&&u8`
- found mutable reference `&mut &mut u8`
+ = note: expected reference `&&_`
+ found mutable reference `&mut &mut _`
= note: a binding must have the same type in all alternatives
error[E0308]: mismatched types
diff --git a/tests/ui/or-patterns/inner-or-pat.or3.stderr b/tests/ui/or-patterns/inner-or-pat.or3.stderr
index 2236a38c3..10ec7c202 100644
--- a/tests/ui/or-patterns/inner-or-pat.or3.stderr
+++ b/tests/ui/or-patterns/inner-or-pat.or3.stderr
@@ -6,6 +6,6 @@ LL | match x {
LL | x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) |
| ^^ expected `str`, found `()`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/or-patterns/inner-or-pat.or4.stderr b/tests/ui/or-patterns/inner-or-pat.or4.stderr
index 058873ff5..97800161d 100644
--- a/tests/ui/or-patterns/inner-or-pat.or4.stderr
+++ b/tests/ui/or-patterns/inner-or-pat.or4.stderr
@@ -6,6 +6,6 @@ LL | (x @ "red" | (x @ "blue" | "red")) => {
| |
| variable not in all patterns
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0408`.
diff --git a/tests/ui/or-patterns/while-parsing-this-or-pattern.stderr b/tests/ui/or-patterns/while-parsing-this-or-pattern.stderr
index 7ad62ff99..1f3d2d5d6 100644
--- a/tests/ui/or-patterns/while-parsing-this-or-pattern.stderr
+++ b/tests/ui/or-patterns/while-parsing-this-or-pattern.stderr
@@ -6,5 +6,5 @@ LL | Some(42) | .=. => {}
| |
| while parsing this or-pattern starting here
-error: aborting due to previous error
+error: aborting due to 1 previous error