Skip to content

Commit 342ea15

Browse files
committed
Add tests
1 parent d8b44d2 commit 342ea15

File tree

4 files changed

+72
-56
lines changed

4 files changed

+72
-56
lines changed

tests/ui/pattern/never_patterns.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,3 @@ fn never_pattern_location(void: Void) {
7474
Some(&(_, !)),
7575
}
7676
}
77-
78-
fn never_and_bindings() {
79-
let x: Result<bool, &(u32, Void)> = Ok(false);
80-
81-
// FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings.
82-
match x {
83-
Ok(_x) | Err(&!) => {}
84-
//~^ ERROR: is not bound in all patterns
85-
}
86-
let (Ok(_x) | Err(&!)) = x;
87-
//~^ ERROR: is not bound in all patterns
88-
89-
// FIXME(never_patterns): A never pattern mustn't have bindings.
90-
match x {
91-
Ok(_) => {}
92-
Err(&(_b, !)),
93-
}
94-
match x {
95-
Ok(_a) | Err(&(_b, !)) => {}
96-
//~^ ERROR: is not bound in all patterns
97-
//~| ERROR: is not bound in all patterns
98-
}
99-
}

tests/ui/pattern/never_patterns.stderr

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,6 @@ LL | let (Ok(_x) | Err(&!)) = res.as_ref();
1414
| |
1515
| variable not in all patterns
1616

17-
error[E0408]: variable `_x` is not bound in all patterns
18-
--> $DIR/never_patterns.rs:83:18
19-
|
20-
LL | Ok(_x) | Err(&!) => {}
21-
| -- ^^^^^^^ pattern doesn't bind `_x`
22-
| |
23-
| variable not in all patterns
24-
25-
error[E0408]: variable `_x` is not bound in all patterns
26-
--> $DIR/never_patterns.rs:86:19
27-
|
28-
LL | let (Ok(_x) | Err(&!)) = x;
29-
| -- ^^^^^^^ pattern doesn't bind `_x`
30-
| |
31-
| variable not in all patterns
32-
33-
error[E0408]: variable `_b` is not bound in all patterns
34-
--> $DIR/never_patterns.rs:95:9
35-
|
36-
LL | Ok(_a) | Err(&(_b, !)) => {}
37-
| ^^^^^^ -- variable not in all patterns
38-
| |
39-
| pattern doesn't bind `_b`
40-
41-
error[E0408]: variable `_a` is not bound in all patterns
42-
--> $DIR/never_patterns.rs:95:18
43-
|
44-
LL | Ok(_a) | Err(&(_b, !)) => {}
45-
| -- ^^^^^^^^^^^^^ pattern doesn't bind `_a`
46-
| |
47-
| variable not in all patterns
48-
49-
error: aborting due to 6 previous errors
17+
error: aborting due to 2 previous errors
5018

5119
For more information about this error, try `rustc --explain E0408`.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(never_patterns)]
2+
#![allow(incomplete_features)]
3+
4+
enum Void {}
5+
6+
fn main() {
7+
let x: Result<bool, &(u32, u32, Void)> = Ok(false);
8+
9+
// FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings.
10+
match x {
11+
Ok(_x) | Err(&!) => {}
12+
//~^ ERROR: is not bound in all patterns
13+
}
14+
let (Ok(_x) | Err(&!)) = x;
15+
//~^ ERROR: is not bound in all patterns
16+
17+
// FIXME(never_patterns): A never pattern mustn't have bindings.
18+
match x {
19+
Ok(_) => {}
20+
Err(&(_a, _b, !)),
21+
}
22+
match x {
23+
Ok(_ok) | Err(&(_a, _b, !)) => {}
24+
//~^ ERROR: is not bound in all patterns
25+
//~| ERROR: is not bound in all patterns
26+
//~| ERROR: is not bound in all patterns
27+
}
28+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0408]: variable `_x` is not bound in all patterns
2+
--> $DIR/bindings.rs:11:18
3+
|
4+
LL | Ok(_x) | Err(&!) => {}
5+
| -- ^^^^^^^ pattern doesn't bind `_x`
6+
| |
7+
| variable not in all patterns
8+
9+
error[E0408]: variable `_x` is not bound in all patterns
10+
--> $DIR/bindings.rs:14:19
11+
|
12+
LL | let (Ok(_x) | Err(&!)) = x;
13+
| -- ^^^^^^^ pattern doesn't bind `_x`
14+
| |
15+
| variable not in all patterns
16+
17+
error[E0408]: variable `_a` is not bound in all patterns
18+
--> $DIR/bindings.rs:23:9
19+
|
20+
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
21+
| ^^^^^^^ -- variable not in all patterns
22+
| |
23+
| pattern doesn't bind `_a`
24+
25+
error[E0408]: variable `_b` is not bound in all patterns
26+
--> $DIR/bindings.rs:23:9
27+
|
28+
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
29+
| ^^^^^^^ -- variable not in all patterns
30+
| |
31+
| pattern doesn't bind `_b`
32+
33+
error[E0408]: variable `_ok` is not bound in all patterns
34+
--> $DIR/bindings.rs:23:19
35+
|
36+
LL | Ok(_ok) | Err(&(_a, _b, !)) => {}
37+
| --- ^^^^^^^^^^^^^^^^^ pattern doesn't bind `_ok`
38+
| |
39+
| variable not in all patterns
40+
41+
error: aborting due to 5 previous errors
42+
43+
For more information about this error, try `rustc --explain E0408`.

0 commit comments

Comments
 (0)