Skip to content

Commit d8a216b

Browse files
committed
address review: modify ICE-133063-never-arm-no-otherwise-block.rs
- Use enum Void to avoid mismatched types error - We don't need to use if let to check the ICE Signed-off-by: Shunpoco <[email protected]>
1 parent e7db092 commit d8a216b

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1+
#![feature(never_type)]
12
#![feature(never_patterns)]
2-
#![feature(if_let_guard)]
33
#![allow(incomplete_features)]
44

5-
fn split_last(_: &()) -> Option<(&i32, &i32)> {
6-
None
7-
}
5+
enum Void {}
86

9-
fn assign_twice() {
7+
fn foo(x: Void) {
108
loop {
11-
match () {
12-
(!| //~ ERROR: mismatched types
13-
!) if let _ = split_last(&()) => {} //~ ERROR a never pattern is always unreachable
14-
//~^ ERROR: mismatched types
15-
//~^^ WARNING: irrefutable `if let` guard pattern [irrefutable_let_patterns]
9+
match x {
10+
(!|!) if false => {} //~ ERROR a never pattern is always unreachable
1611
_ => {}
1712
}
1813
}
Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
11
error: a never pattern is always unreachable
2-
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:46
2+
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:10:31
33
|
4-
LL | !) if let _ = split_last(&()) => {}
5-
| ^^
6-
| |
7-
| this will never be executed
8-
| help: remove this expression
4+
LL | (!|!) if false => {}
5+
| ^^
6+
| |
7+
| this will never be executed
8+
| help: remove this expression
99

10-
error: mismatched types
11-
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:12:14
12-
|
13-
LL | (!|
14-
| ^ a never pattern must be used on an uninhabited type
15-
|
16-
= note: the matched value is of type `()`
17-
18-
error: mismatched types
19-
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:13
20-
|
21-
LL | !) if let _ = split_last(&()) => {}
22-
| ^ a never pattern must be used on an uninhabited type
23-
|
24-
= note: the matched value is of type `()`
25-
26-
warning: irrefutable `if let` guard pattern
27-
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:19
28-
|
29-
LL | !) if let _ = split_last(&()) => {}
30-
| ^^^^^^^^^^^^^^^^^^^^^^^
31-
|
32-
= note: this pattern will always match, so the guard is useless
33-
= help: consider removing the guard and adding a `let` inside the match arm
34-
= note: `#[warn(irrefutable_let_patterns)]` on by default
35-
36-
error: aborting due to 3 previous errors; 1 warning emitted
10+
error: aborting due to 1 previous error
3711

0 commit comments

Comments
 (0)