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 <tkngsnsk313320@gmail.com>
This commit is contained in:
Shunpoco 2025-01-22 01:27:15 +00:00
parent e7db0925d1
commit d8a216b866
2 changed files with 12 additions and 43 deletions

View file

@ -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
_ => {}
}
}

View file

@ -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