Skip to content

Commit

Permalink
address review: modify ICE-133063-never-arm-no-otherwise-block.rs
Browse files Browse the repository at this point in the history
- Use enum Void to avoid mismatched types error
- We don't need to use if let to check the ICE

Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
  • Loading branch information
Shunpoco committed Jan 22, 2025
1 parent e7db092 commit d8a216b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#![feature(never_type)]
#![feature(never_patterns)]
#![feature(if_let_guard)]
#![allow(incomplete_features)]

fn split_last(_: &()) -> Option<(&i32, &i32)> {
None
}
enum Void {}

fn assign_twice() {
fn foo(x: Void) {
loop {
match () {
(!| //~ ERROR: mismatched types
!) if let _ = split_last(&()) => {} //~ ERROR a never pattern is always unreachable
//~^ ERROR: mismatched types
//~^^ WARNING: irrefutable `if let` guard pattern [irrefutable_let_patterns]
match x {
(!|!) if false => {} //~ ERROR a never pattern is always unreachable
_ => {}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
error: a never pattern is always unreachable
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:46
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:10:31
|
LL | !) if let _ = split_last(&()) => {}
| ^^
| |
| this will never be executed
| help: remove this expression
LL | (!|!) if false => {}
| ^^
| |
| this will never be executed
| help: remove this expression

error: mismatched types
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:12:14
|
LL | (!|
| ^ a never pattern must be used on an uninhabited type
|
= note: the matched value is of type `()`

error: mismatched types
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:13
|
LL | !) if let _ = split_last(&()) => {}
| ^ a never pattern must be used on an uninhabited type
|
= note: the matched value is of type `()`

warning: irrefutable `if let` guard pattern
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:19
|
LL | !) if let _ = split_last(&()) => {}
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this pattern will always match, so the guard is useless
= help: consider removing the guard and adding a `let` inside the match arm
= note: `#[warn(irrefutable_let_patterns)]` on by default

error: aborting due to 3 previous errors; 1 warning emitted
error: aborting due to 1 previous error

0 comments on commit d8a216b

Please sign in to comment.