Skip to content

Commit e06de16

Browse files
committed
Add miri tests for terminate terminator
1 parent 2a9d710 commit e06de16

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@compile-flags: -Zmir-opt-level=3
2+
// Enable MIR inlining to ensure that `TerminatorKind::Terminate` is generated
3+
// instead of just `UnwindAction::Terminate`.
4+
5+
#![feature(c_unwind)]
6+
7+
struct Foo;
8+
9+
impl Drop for Foo {
10+
fn drop(&mut self) {}
11+
}
12+
13+
#[inline(always)]
14+
fn has_cleanup() {
15+
//~^ ERROR: panic in a function that cannot unwind
16+
// FIXME(nbdd0121): The error should be reported at the call site.
17+
let _f = Foo;
18+
panic!();
19+
}
20+
21+
extern "C" fn panic_abort() {
22+
has_cleanup();
23+
}
24+
25+
fn main() {
26+
panic_abort();
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
thread 'main' panicked at 'explicit panic', $DIR/terminate-terminator.rs:LL:CC
2+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3+
error: abnormal termination: panic in a function that cannot unwind
4+
--> $DIR/terminate-terminator.rs:LL:CC
5+
|
6+
LL | / fn has_cleanup() {
7+
LL | |
8+
LL | | // FIXME(nbdd0121): The error should be reported at the call site.
9+
LL | | let _f = Foo;
10+
LL | | panic!();
11+
LL | | }
12+
| |_^ panic in a function that cannot unwind
13+
...
14+
LL | has_cleanup();
15+
| ------------- in this inlined function call
16+
|
17+
= note: inside `panic_abort` at $DIR/terminate-terminator.rs:LL:CC
18+
note: inside `main`
19+
--> $DIR/terminate-terminator.rs:LL:CC
20+
|
21+
LL | panic_abort();
22+
| ^^^^^^^^^^^^^
23+
24+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
25+
26+
error: aborting due to previous error
27+

src/tools/miri/tests/fail/abort-terminator.stderr renamed to src/tools/miri/tests/fail/unwind-action-terminate.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
thread 'main' panicked at 'explicit panic', $DIR/abort-terminator.rs:LL:CC
1+
thread 'main' panicked at 'explicit panic', $DIR/unwind-action-terminate.rs:LL:CC
22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
33
error: abnormal termination: panic in a function that cannot unwind
4-
--> $DIR/abort-terminator.rs:LL:CC
4+
--> $DIR/unwind-action-terminate.rs:LL:CC
55
|
66
LL | / extern "C" fn panic_abort() {
77
LL | |
88
LL | | panic!()
99
LL | | }
1010
| |_^ panic in a function that cannot unwind
1111
|
12-
= note: inside `panic_abort` at $DIR/abort-terminator.rs:LL:CC
12+
= note: inside `panic_abort` at $DIR/unwind-action-terminate.rs:LL:CC
1313
note: inside `main`
14-
--> $DIR/abort-terminator.rs:LL:CC
14+
--> $DIR/unwind-action-terminate.rs:LL:CC
1515
|
1616
LL | panic_abort();
1717
| ^^^^^^^^^^^^^

0 commit comments

Comments
 (0)