Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_mir_build/src/builder/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

valtree
}
Err(ErrorHandled::Reported(..)) => return self.cfg.start_new_block().unit(),
Err(ErrorHandled::Reported(..)) => {
return block.unit();
}
Err(ErrorHandled::TooGeneric(_)) => {
self.tcx.dcx().emit_fatal(ConstContinueBadConst { span: constant.span });
}
Expand Down
22 changes: 22 additions & 0 deletions tests/ui/loop-match/panic-in-const.rs
Original file line number Diff line number Diff line change
@@ -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!(),
}
}
}
}
9 changes: 9 additions & 0 deletions tests/ui/loop-match/panic-in-const.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading