Skip to content

Commit e7db092

Browse files
committed
address review: modify ICE-133117-duplicated-never-arm.rs
Use enum Void to avoid mistmatched types error Signed-off-by: Shunpoco <[email protected]>
1 parent 0385dd4 commit e7db092

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
#![feature(never_type)]
12
#![feature(never_patterns)]
23
#![allow(incomplete_features)]
34

4-
fn main() {
5-
match () {
6-
(!|
7-
//~^ ERROR: mismatched types
8-
!) if true => {} //~ ERROR a never pattern is always unreachable
9-
//~^ ERROR: mismatched types
5+
enum Void {}
6+
7+
fn foo(x: Void) {
8+
match x {
9+
(!|!) if true => {} //~ ERROR a never pattern is always unreachable
1010
(!|!) if true => {} //~ ERROR a never pattern is always unreachable
1111
}
1212
}
13+
14+
fn main() {}
Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: a never pattern is always unreachable
2-
--> $DIR/ICE-133117-duplicate-never-arm.rs:8:23
2+
--> $DIR/ICE-133117-duplicate-never-arm.rs:9:26
33
|
4-
LL | !) if true => {}
5-
| ^^
6-
| |
7-
| this will never be executed
8-
| help: remove this expression
4+
LL | (!|!) if true => {}
5+
| ^^
6+
| |
7+
| this will never be executed
8+
| help: remove this expression
99

1010
error: a never pattern is always unreachable
1111
--> $DIR/ICE-133117-duplicate-never-arm.rs:10:26
@@ -16,21 +16,5 @@ LL | (!|!) if true => {}
1616
| this will never be executed
1717
| help: remove this expression
1818

19-
error: mismatched types
20-
--> $DIR/ICE-133117-duplicate-never-arm.rs:6:10
21-
|
22-
LL | (!|
23-
| ^ a never pattern must be used on an uninhabited type
24-
|
25-
= note: the matched value is of type `()`
26-
27-
error: mismatched types
28-
--> $DIR/ICE-133117-duplicate-never-arm.rs:8:9
29-
|
30-
LL | !) if true => {}
31-
| ^ a never pattern must be used on an uninhabited type
32-
|
33-
= note: the matched value is of type `()`
34-
35-
error: aborting due to 4 previous errors
19+
error: aborting due to 2 previous errors
3620

0 commit comments

Comments
 (0)