From d8a216b866ff238589005fb1ea4c54644d8d24bf Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 22 Jan 2025 01:27:15 +0000 Subject: [PATCH] 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 --- ...ICE-133063-never-arm-no-otherwise-block.rs | 15 +++---- ...133063-never-arm-no-otherwise-block.stderr | 40 ++++--------------- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs index a9527d7d0c445..4f52f6ee4bd91 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs @@ -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 _ => {} } } diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr index 896c95f1866fe..cc451fed31805 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr @@ -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