with this, we support panics on Windows

This commit is contained in:
Ralf Jung 2020-06-27 14:43:37 +02:00
parent 8e92969948
commit e54619b5e1
28 changed files with 10 additions and 67 deletions

View file

@ -129,7 +129,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// This matches calls to the foreign item `panic_impl`.
// The implementation is provided by the function with the `#[panic_handler]` attribute.
"panic_impl" => {
this.check_panic_supported()?;
let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));

View file

@ -52,14 +52,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
return this.emulate_foreign_item(instance.def_id(), args, ret, unwind);
}
// Better error message for panics on Windows.
let def_id = instance.def_id();
if Some(def_id) == this.tcx.lang_items().begin_panic_fn() ||
Some(def_id) == this.tcx.lang_items().panic_impl()
{
this.check_panic_supported()?;
}
// Otherwise, load the MIR.
Ok(Some(&*this.load_mir(instance.def, None)?))
}

View file

@ -34,14 +34,6 @@ pub struct CatchUnwindData<'tcx> {
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
/// Check if panicking is supported on this target, and give a good error otherwise.
fn check_panic_supported(&self) -> InterpResult<'tcx> {
match self.eval_context_ref().tcx.sess.target.target.target_os.as_str() {
"linux" | "macos" => Ok(()),
_ => throw_unsup_format!("panicking is not supported on this target"),
}
}
/// Handles the special `miri_start_panic` intrinsic, which is called
/// by libpanic_unwind to delegate the actual unwinding process to Miri.
fn handle_miri_start_panic(

View file

@ -1,5 +1,4 @@
// error-pattern: the evaluated program aborted
// ignore-windows (panics dont work on Windows)
#![feature(unwind_attributes)]
#[unwind(aborts)]

View file

@ -1,5 +1,4 @@
// error-pattern: the evaluated program aborted
// ignore-windows (panics dont work on Windows)
struct Foo;
impl Drop for Foo {

View file

@ -1,9 +0,0 @@
// ignore-linux
// ignore-macos
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this target
fn main() {
core::panic!("this is {}", "Windows");
}

View file

@ -1,9 +0,0 @@
// ignore-linux
// ignore-macos
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this target
fn main() {
std::panic!("this is Windows");
}

View file

@ -1,10 +0,0 @@
// ignore-linux
// ignore-macos
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this target
#[allow(unconditional_panic)]
fn main() {
let _val = 1/0;
}

View file

@ -1,7 +1,7 @@
// ignore-windows: Unwind panicking does not currently work on Windows
// normalize-stderr-test "[^ ]*libcore/[a-z/]+.rs[0-9:]*" -> "$$LOC"
#![feature(never_type)]
#![allow(unconditional_panic)]
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::cell::Cell;

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(unconditional_panic)]
fn main() {

View file

@ -1 +1 @@
thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:5:14
thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:4:14

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(arithmetic_overflow)]
fn main() {

View file

@ -1 +1 @@
thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:5:14
thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:4:14

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(arithmetic_overflow)]
fn main() {

View file

@ -1 +1 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:5:14
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:4:14

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![allow(arithmetic_overflow)]
fn main() {

View file

@ -1 +1 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:6:14
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:5:14

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
std::panic!("panicking from libstd");
}

View file

@ -1 +1 @@
thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:3:5
thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:2:5

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
std::panic!("{}-panicking from libstd", 42);
}

View file

@ -1 +1 @@
thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:3:5
thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:2:5

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
core::panic!("panicking from libcore");
}

View file

@ -1 +1 @@
thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:3:5
thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:2:5

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
core::panic!("{}-panicking from libcore", 42);
}

View file

@ -1 +1 @@
thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:3:5
thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:2:5

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
#![feature(option_expect_none, option_unwrap_none)]
//! Test that panic locations for `#[track_caller]` functions in std have the correct
//! location reported.

View file

@ -1,4 +1,3 @@
// ignore-windows: Unwind panicking does not currently work on Windows
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {

View file

@ -1 +1 @@
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:12:5
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:11:5