Skip to content

Commit a0104a9

Browse files
authored
Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors
custom mir: make it clear what the return block is Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments: ``` Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue()) ``` Also fix some outdated docs and add some docs to `Call` and `Drop`.
2 parents 18db6d1 + 7cb83db commit a0104a9

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, UnwindContinue())
17+
Call(_unit = callee(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
LL | Call(_unit = callee(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(_unit = callee(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
14+
Call(_unit = change_arg(Move(non_copy)), ReturnTo(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, UnwindContinue())
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
17+
Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(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, UnwindContinue())
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | Call(*ptr = myfun(ptr), ReturnTo(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, UnwindContinue())
18+
Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
1919
}
2020

2121
after_call = {

tests/fail/function_calls/return_pointer_aliasing.stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ LL | unsafe { ptr.read() };
2727
note: inside `main`
2828
--> $DIR/return_pointer_aliasing.rs:LL:CC
2929
|
30-
LL | Call(*ptr = myfun(ptr), after_call, UnwindContinue())
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
LL | Call(*ptr = myfun(ptr), ReturnTo(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/return_pointer_aliasing.tree.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ LL | unsafe { ptr.read() };
3535
note: inside `main`
3636
--> $DIR/return_pointer_aliasing.rs:LL:CC
3737
|
38-
LL | Call(*ptr = myfun(ptr), after_call, UnwindContinue())
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(*ptr = myfun(ptr), ReturnTo(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_aliasing2.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(_x = myfun(ptr), after_call, UnwindContinue())
18+
Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
1919
}
2020

2121
after_call = {

tests/fail/function_calls/return_pointer_aliasing2.stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ LL | unsafe { ptr.write(0) };
3030
note: inside `main`
3131
--> $DIR/return_pointer_aliasing2.rs:LL:CC
3232
|
33-
LL | Call(_x = myfun(ptr), after_call, UnwindContinue())
34-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3535
= 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)
3636

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

tests/fail/function_calls/return_pointer_aliasing2.tree.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ LL | unsafe { ptr.write(0) };
3535
note: inside `main`
3636
--> $DIR/return_pointer_aliasing2.rs:LL:CC
3737
|
38-
LL | Call(_x = myfun(ptr), after_call, UnwindContinue())
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
LL | Call(_x = myfun(ptr), ReturnTo(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_on_unwind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct S(i32, [u8; 128]);
1414
fn docall(out: &mut S) {
1515
mir! {
1616
{
17-
Call(*out = callee(), after_call, UnwindContinue())
17+
Call(*out = callee(), ReturnTo(after_call), UnwindContinue())
1818
}
1919

2020
after_call = {
@@ -37,7 +37,7 @@ fn callee() -> S {
3737
// become visible to the outside. In codegen we can see them
3838
// but Miri should detect this as UB!
3939
RET.0 = 42;
40-
Call(_unit = startpanic(), after_call, UnwindContinue())
40+
Call(_unit = startpanic(), ReturnTo(after_call), UnwindContinue())
4141
}
4242

4343
after_call = {

tests/fail/validity/cast_fn_ptr_invalid_caller_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn call(f: fn(NonZeroU32)) {
2020
let tmp = ptr::addr_of!(c);
2121
let ptr = tmp as *const NonZeroU32;
2222
// The call site now is a NonZeroU32-to-u32 transmute.
23-
Call(_res = f(*ptr), retblock, UnwindContinue()) //~ERROR: expected something greater or equal to 1
23+
Call(_res = f(*ptr), ReturnTo(retblock), UnwindContinue()) //~ERROR: expected something greater or equal to 1
2424
}
2525
retblock = {
2626
Return()

tests/fail/validity/cast_fn_ptr_invalid_caller_arg.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: constructing invalid value: encountered 0, but expected something greater or equal to 1
22
--> $DIR/cast_fn_ptr_invalid_caller_arg.rs:LL:CC
33
|
4-
LL | Call(_res = f(*ptr), retblock, UnwindContinue())
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
4+
LL | Call(_res = f(*ptr), ReturnTo(retblock), UnwindContinue())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/pass/function_calls/return_place_on_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn main() {
1111
{
1212
let x = 0;
1313
let ptr = &raw mut x;
14-
Call(*ptr = myfun(), after_call, UnwindContinue())
14+
Call(*ptr = myfun(), ReturnTo(after_call), UnwindContinue())
1515
}
1616

1717
after_call = {

0 commit comments

Comments
 (0)