Skip to content

Commit df3a569

Browse files
committed
Custom MIR: Support cleanup blocks
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
1 parent 1a8b516 commit df3a569

19 files changed

+31
-31
lines changed

tests/fail/function_calls/arg_inplace_mutate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
let ptr = std::ptr::addr_of_mut!(non_copy);
1515
// Inside `callee`, the first argument and `*ptr` are basically
1616
// aliasing places!
17-
Call(_unit = callee(Move(*ptr), ptr), after_call)
17+
Call(_unit = callee(Move(*ptr), ptr), after_call, UnwindContinue())
1818
}
1919
after_call = {
2020
Return()

tests/fail/function_calls/arg_inplace_mutate.stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ LL | unsafe { ptr.write(S(0)) };
2727
note: inside `main`
2828
--> $DIR/arg_inplace_mutate.rs:LL:CC
2929
|
30-
LL | Call(_unit = callee(Move(*ptr), ptr), after_call)
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
LL | Call(_unit = callee(Move(*ptr), ptr), after_call, UnwindContinue())
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232
= note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info)
3333

3434
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/function_calls/arg_inplace_mutate.tree.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ LL | unsafe { ptr.write(S(0)) };
3535
note: inside `main`
3636
--> $DIR/arg_inplace_mutate.rs:LL:CC
3737
|
38-
LL | Call(_unit = callee(Move(*ptr), ptr), after_call)
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(_unit = callee(Move(*ptr), ptr), after_call, UnwindContinue())
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4040
= note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info)
4141

4242
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/function_calls/arg_inplace_observe_after.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main() {
1111
{
1212
let non_copy = S(42);
1313
// This could change `non_copy` in-place
14-
Call(_unit = change_arg(Move(non_copy)), after_call)
14+
Call(_unit = change_arg(Move(non_copy)), after_call, UnwindContinue())
1515
}
1616
after_call = {
1717
// So now we must not be allowed to observe non-copy again.

tests/fail/function_calls/arg_inplace_observe_during.none.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | unsafe { ptr.read() };
1111
note: inside `main`
1212
--> $DIR/arg_inplace_observe_during.rs:LL:CC
1313
|
14-
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call)
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call, UnwindContinue())
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

tests/fail/function_calls/arg_inplace_observe_during.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
let non_copy = S(42);
1515
let ptr = std::ptr::addr_of_mut!(non_copy);
1616
// This could change `non_copy` in-place
17-
Call(_unit = change_arg(Move(*ptr), ptr), after_call)
17+
Call(_unit = change_arg(Move(*ptr), ptr), after_call, UnwindContinue())
1818
}
1919
after_call = {
2020
Return()

tests/fail/function_calls/arg_inplace_observe_during.stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ LL | x.0 = 0;
2727
note: inside `main`
2828
--> $DIR/arg_inplace_observe_during.rs:LL:CC
2929
|
30-
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call)
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call, UnwindContinue())
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232
= note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info)
3333

3434
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/function_calls/arg_inplace_observe_during.tree.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ LL | x.0 = 0;
3535
note: inside `main`
3636
--> $DIR/arg_inplace_observe_during.rs:LL:CC
3737
|
38-
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call)
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(_unit = change_arg(Move(*ptr), ptr), after_call, UnwindContinue())
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4040
= note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info)
4141

4242
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/function_calls/return_pointer_aliasing.none.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | unsafe { ptr.read() };
1111
note: inside `main`
1212
--> $DIR/return_pointer_aliasing.rs:LL:CC
1313
|
14-
LL | Call(*ptr = myfun(ptr), after_call)
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | Call(*ptr = myfun(ptr), after_call, UnwindContinue())
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

tests/fail/function_calls/return_pointer_aliasing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn main() {
1515
let ptr = &raw mut x;
1616
// We arrange for `myfun` to have a pointer that aliases
1717
// its return place. Even just reading from that pointer is UB.
18-
Call(*ptr = myfun(ptr), after_call)
18+
Call(*ptr = myfun(ptr), after_call, UnwindContinue())
1919
}
2020

2121
after_call = {

0 commit comments

Comments
 (0)