forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add miri tests for terminate terminator
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...s/miri/tests/fail/abort-terminator.stderr → ...tests/fail/unwind-action-terminate.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters