From 6d58a88c3ca2eefc24654700db522bfed668e1cb Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Mon, 7 Jul 2025 13:55:40 +0200 Subject: `loop_match`: fix 'no terminator on block' --- tests/ui/loop-match/panic-in-const.rs | 22 ++++++++++++++++++++++ tests/ui/loop-match/panic-in-const.stderr | 9 +++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/ui/loop-match/panic-in-const.rs create mode 100644 tests/ui/loop-match/panic-in-const.stderr (limited to 'tests') diff --git a/tests/ui/loop-match/panic-in-const.rs b/tests/ui/loop-match/panic-in-const.rs new file mode 100644 index 00000000000..2ae67445496 --- /dev/null +++ b/tests/ui/loop-match/panic-in-const.rs @@ -0,0 +1,22 @@ +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +const CONST_THAT_PANICS: u8 = panic!("diverge!"); +//~^ ERROR: evaluation panicked: diverge! + +fn test(mut state: u8) { + #[loop_match] + loop { + state = 'blk: { + match state { + 0 => { + #[const_continue] + break 'blk CONST_THAT_PANICS; + } + + _ => unreachable!(), + } + } + } +} diff --git a/tests/ui/loop-match/panic-in-const.stderr b/tests/ui/loop-match/panic-in-const.stderr new file mode 100644 index 00000000000..b6ed3177883 --- /dev/null +++ b/tests/ui/loop-match/panic-in-const.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation panicked: diverge! + --> $DIR/panic-in-const.rs:5:31 + | +LL | const CONST_THAT_PANICS: u8 = panic!("diverge!"); + | ^^^^^^^^^^^^^^^^^^ evaluation of `CONST_THAT_PANICS` failed here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. -- cgit 1.4.1-3-g733a5