Add miri tests for terminate terminator
This commit is contained in:
parent
2a9d710d99
commit
e06de16a82
27
src/tools/miri/tests/fail/terminate-terminator.rs
Normal file
27
src/tools/miri/tests/fail/terminate-terminator.rs
Normal 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();
|
||||||
|
}
|
27
src/tools/miri/tests/fail/terminate-terminator.stderr
Normal file
27
src/tools/miri/tests/fail/terminate-terminator.stderr
Normal 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
|
||||||
|
|
@ -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
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||||
error: abnormal termination: panic in a function that cannot unwind
|
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 | / extern "C" fn panic_abort() {
|
||||||
LL | |
|
LL | |
|
||||||
@ -9,9 +9,9 @@ LL | | panic!()
|
|||||||
LL | | }
|
LL | | }
|
||||||
| |_^ panic in a function that cannot unwind
|
| |_^ 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`
|
note: inside `main`
|
||||||
--> $DIR/abort-terminator.rs:LL:CC
|
--> $DIR/unwind-action-terminate.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | panic_abort();
|
LL | panic_abort();
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
Loading…
x
Reference in New Issue
Block a user