Skip to content

Commit ddf23cb

Browse files
committed
add new test and combine old ones
1 parent 661d488 commit ddf23cb

File tree

6 files changed

+65
-47
lines changed

6 files changed

+65
-47
lines changed

src/test/ui/or-patterns/inner-or-pat-2.rs

-13
This file was deleted.

src/test/ui/or-patterns/inner-or-pat-3.rs

-15
This file was deleted.

src/test/ui/or-patterns/inner-or-pat-4.rs

-13
This file was deleted.

src/test/ui/or-patterns/inner-or-pat-2.stderr renamed to src/test/ui/or-patterns/inner-or-pat.or3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/inner-or-pat-2.rs:6:54
2+
--> $DIR/inner-or-pat.rs:38:54
33
|
44
LL | match x {
55
| - this expression has type `&str`

src/test/ui/or-patterns/inner-or-pat-4.stderr renamed to src/test/ui/or-patterns/inner-or-pat.or4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0408]: variable `x` is not bound in all patterns
2-
--> $DIR/inner-or-pat-4.rs:8:37
2+
--> $DIR/inner-or-pat.rs:53:37
33
|
44
LL | (x @ "red" | (x @ "blue" | "red")) => {
55
| - ^^^^^ pattern doesn't bind `x`
+63-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
// run-pass
1+
// revisions: or1 or2 or3 or4 or5
2+
// [or1] run-pass
3+
// [or2] run-pass
4+
// [or5] run-pass
25

3-
#[allow(unused_variables)]
4-
#[allow(unused_parens)]
5-
fn main() {
6+
#![allow(unreachable_patterns)]
7+
#![allow(unused_variables)]
8+
#![allow(unused_parens)]
9+
#![allow(dead_code)]
10+
11+
12+
13+
fn foo() {
614
let x = "foo";
715
match x {
816
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | "no" | "nop") | ("hey" | "gg")) |
@@ -12,3 +20,54 @@ fn main() {
1220
_ => (),
1321
}
1422
}
23+
24+
fn bar() {
25+
let x = "foo";
26+
match x {
27+
x @ ("foo" | "bar") |
28+
(x @ "red" | (x @ "blue" | x @ "red")) => {
29+
}
30+
_ => (),
31+
}
32+
}
33+
34+
#[cfg(or3)]
35+
fn zot() {
36+
let x = "foo";
37+
match x {
38+
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) |
39+
//[or3]~^ ERROR mismatched types
40+
x @ ("black" | "pink") |
41+
x @ ("red" | "blue") => {
42+
}
43+
_ => (),
44+
}
45+
}
46+
47+
48+
#[cfg(or4)]
49+
fn hey() {
50+
let x = "foo";
51+
match x {
52+
x @ ("foo" | "bar") |
53+
(x @ "red" | (x @ "blue" | "red")) => {
54+
//[or4]~^ variable `x` is not bound in all patterns
55+
}
56+
_ => (),
57+
}
58+
}
59+
60+
fn don() {
61+
enum Foo {
62+
A,
63+
B,
64+
C,
65+
}
66+
67+
match Foo::A {
68+
| _foo @ (Foo::A | Foo::B) => {}
69+
Foo::C => {}
70+
};
71+
}
72+
73+
fn main(){}

0 commit comments

Comments
 (0)