Skip to content

Commit efcf1ac

Browse files
committed
Auto merge of #1241 - RalfJung:dont-panic, r=RalfJung
whitelist platforms where panicking should work @CAD97 [proposed](#1059 (comment)) trying to get a better error for failed panics on Windows. Could you test if this works for you?
2 parents 0ff05c4 + 0ae6288 commit efcf1ac

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/shims/foreign_items.rs

+6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
132132
// This matches calls to the foreign item `panic_impl`.
133133
// The implementation is provided by the function with the `#[panic_handler]` attribute.
134134
"panic_impl" => {
135+
// Make sure panicking actually works on this platform.
136+
match this.tcx.sess.target.target.target_os.as_str() {
137+
"linux" | "macos" => {},
138+
_ => throw_unsup_format!("panicking is not supported on this platform"),
139+
}
140+
135141
let panic_impl_id = this.tcx.lang_items().panic_impl().unwrap();
136142
let panic_impl_instance = ty::Instance::mono(*this.tcx, panic_impl_id);
137143
return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));

tests/compile-fail/panic/windows.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ignore-linux
2+
// ignore-macos
3+
4+
// Test that panics on Windows give a reasonable error message.
5+
6+
// error-pattern: panicking is not supported on this platform
7+
fn main() {
8+
panic!("this is Windows");
9+
}

0 commit comments

Comments
 (0)