Add miri tests for terminate terminator

This commit is contained in:
Gary Guo 2022-11-19 23:03:22 +00:00
parent 2a9d710d99
commit e06de16a82
4 changed files with 58 additions and 4 deletions

View File

@ -0,0 +1,27 @@
//@compile-flags: -Zmir-opt-level=3
// Enable MIR inlining to ensure that `TerminatorKind::Terminate` is generated
// instead of just `UnwindAction::Terminate`.
#![feature(c_unwind)]
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {}
}
#[inline(always)]
fn has_cleanup() {
//~^ ERROR: panic in a function that cannot unwind
// FIXME(nbdd0121): The error should be reported at the call site.
let _f = Foo;
panic!();
}
extern "C" fn panic_abort() {
has_cleanup();
}
fn main() {
panic_abort();
}

View File

@ -0,0 +1,27 @@
thread 'main' panicked at 'explicit panic', $DIR/terminate-terminator.rs:LL:CC
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/terminate-terminator.rs:LL:CC
|
LL | / fn has_cleanup() {
LL | |
LL | | // FIXME(nbdd0121): The error should be reported at the call site.
LL | | let _f = Foo;
LL | | panic!();
LL | | }
| |_^ panic in a function that cannot unwind
...
LL | has_cleanup();
| ------------- in this inlined function call
|
= note: inside `panic_abort` at $DIR/terminate-terminator.rs:LL:CC
note: inside `main`
--> $DIR/terminate-terminator.rs:LL:CC
|
LL | panic_abort();
| ^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error

View File

@ -1,7 +1,7 @@
thread 'main' panicked at 'explicit panic', $DIR/abort-terminator.rs:LL:CC
thread 'main' panicked at 'explicit panic', $DIR/unwind-action-terminate.rs:LL:CC
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/abort-terminator.rs:LL:CC
--> $DIR/unwind-action-terminate.rs:LL:CC
|
LL | / extern "C" fn panic_abort() {
LL | |
@ -9,9 +9,9 @@ LL | | panic!()
LL | | }
| |_^ panic in a function that cannot unwind
|
= note: inside `panic_abort` at $DIR/abort-terminator.rs:LL:CC
= note: inside `panic_abort` at $DIR/unwind-action-terminate.rs:LL:CC
note: inside `main`
--> $DIR/abort-terminator.rs:LL:CC
--> $DIR/unwind-action-terminate.rs:LL:CC
|
LL | panic_abort();
| ^^^^^^^^^^^^^