Skip to content

Commit 2d62db7

Browse files
authored
Rollup merge of rust-lang#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 7aaa1eb + 4bf2794 commit 2d62db7

36 files changed

+120
-78
lines changed

compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
6161
@call(mir_drop, args) => {
6262
Ok(TerminatorKind::Drop {
6363
place: self.parse_place(args[0])?,
64-
target: self.parse_block(args[1])?,
64+
target: self.parse_return_to(args[1])?,
6565
unwind: self.parse_unwind_action(args[2])?,
6666
replace: false,
6767
})
@@ -104,6 +104,14 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
104104
)
105105
}
106106

107+
fn parse_return_to(&self, expr_id: ExprId) -> PResult<BasicBlock> {
108+
parse_by_kind!(self, expr_id, _, "return block",
109+
@call(mir_return_to, args) => {
110+
self.parse_block(args[0])
111+
},
112+
)
113+
}
114+
107115
fn parse_match(&self, arms: &[ArmId], span: Span) -> PResult<SwitchTargets> {
108116
let Some((otherwise, rest)) = arms.split_last() else {
109117
return Err(ParseError {
@@ -146,7 +154,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
146154
ExprKind::Assign { lhs, rhs } => (*lhs, *rhs),
147155
);
148156
let destination = self.parse_place(destination)?;
149-
let target = self.parse_block(args[1])?;
157+
let target = self.parse_return_to(args[1])?;
150158
let unwind = self.parse_unwind_action(args[2])?;
151159

152160
parse_by_kind!(self, call, _, "function call",

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ symbols! {
10411041
mir_offset,
10421042
mir_retag,
10431043
mir_return,
1044+
mir_return_to,
10441045
mir_set_discriminant,
10451046
mir_static,
10461047
mir_static_mut,

library/core/src/intrinsics/mir.rs

+45-12
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,22 @@
104104
//! }
105105
//!
106106
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
107+
#![cfg_attr(bootstrap, doc = "#[cfg(any())]")] // disable the following function in doctests when `bootstrap` is set
107108
//! fn push_and_pop<T>(v: &mut Vec<T>, value: T) {
108109
//! mir!(
109110
//! let _unused;
110111
//! let popped;
111112
//!
112113
//! {
113-
//! Call(_unused = Vec::push(v, value), pop, UnwindContinue())
114+
//! Call(_unused = Vec::push(v, value), ReturnTo(pop), UnwindContinue())
114115
//! }
115116
//!
116117
//! pop = {
117-
//! Call(popped = Vec::pop(v), drop, UnwindContinue())
118+
//! Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue())
118119
//! }
119120
//!
120121
//! drop = {
121-
//! Drop(popped, ret, UnwindContinue())
122+
//! Drop(popped, ReturnTo(ret), UnwindContinue())
122123
//! }
123124
//!
124125
//! ret = {
@@ -242,9 +243,8 @@
242243
//! - `match some_int_operand` becomes a `SwitchInt`. Each arm should be `literal => basic_block`
243244
//! - The exception is the last arm, which must be `_ => basic_block` and corresponds to the
244245
//! otherwise branch.
245-
//! - [`Call`] has an associated function as well. The third argument of this function is a normal
246-
//! function call expression, for example `my_other_function(a, 5)`.
247-
//!
246+
//! - [`Call`] has an associated function as well, with special syntax:
247+
//! `Call(ret_val = function(arg1, arg2, ...), ReturnTo(next_block), UnwindContinue())`.
248248
249249
#![unstable(
250250
feature = "custom_mir",
@@ -287,35 +287,68 @@ macro_rules! define {
287287
}
288288

289289
// Unwind actions
290+
pub struct UnwindActionArg;
290291
define!(
291292
"mir_unwind_continue",
292293
/// An unwind action that continues unwinding.
293-
fn UnwindContinue()
294+
fn UnwindContinue() -> UnwindActionArg
294295
);
295296
define!(
296297
"mir_unwind_unreachable",
297298
/// An unwind action that triggers undefined behaviour.
298-
fn UnwindUnreachable() -> BasicBlock
299+
fn UnwindUnreachable() -> UnwindActionArg
299300
);
300301
define!(
301302
"mir_unwind_terminate",
302303
/// An unwind action that terminates the execution.
303304
///
304305
/// `UnwindTerminate` can also be used as a terminator.
305-
fn UnwindTerminate(reason: UnwindTerminateReason)
306+
fn UnwindTerminate(reason: UnwindTerminateReason) -> UnwindActionArg
306307
);
307308
define!(
308309
"mir_unwind_cleanup",
309310
/// An unwind action that continues execution in a given basic blok.
310-
fn UnwindCleanup(goto: BasicBlock)
311+
fn UnwindCleanup(goto: BasicBlock) -> UnwindActionArg
311312
);
312313

314+
// Return destination for `Call`
315+
pub struct ReturnToArg;
316+
define!("mir_return_to", fn ReturnTo(goto: BasicBlock) -> ReturnToArg);
317+
313318
// Terminators
314319
define!("mir_return", fn Return() -> BasicBlock);
315320
define!("mir_goto", fn Goto(destination: BasicBlock) -> BasicBlock);
316321
define!("mir_unreachable", fn Unreachable() -> BasicBlock);
317-
define!("mir_drop", fn Drop<T, U>(place: T, goto: BasicBlock, unwind_action: U));
318-
define!("mir_call", fn Call<U>(call: (), goto: BasicBlock, unwind_action: U));
322+
define!("mir_drop",
323+
/// Drop the contents of a place.
324+
///
325+
/// The first argument must be a place.
326+
///
327+
/// The second argument must be of the form `ReturnTo(bb)`, where `bb` is the basic block that
328+
/// will be jumped to after the destructor returns.
329+
///
330+
/// The third argument describes what happens on unwind. It can be one of:
331+
/// - [`UnwindContinue`]
332+
/// - [`UnwindUnreachable`]
333+
/// - [`UnwindTerminate`]
334+
/// - [`UnwindCleanup`]
335+
fn Drop<T>(place: T, goto: ReturnToArg, unwind_action: UnwindActionArg)
336+
);
337+
define!("mir_call",
338+
/// Call a function.
339+
///
340+
/// The first argument must be of the form `ret_val = fun(arg1, arg2, ...)`.
341+
///
342+
/// The second argument must be of the form `ReturnTo(bb)`, where `bb` is the basic block that
343+
/// will be jumped to after the function returns.
344+
///
345+
/// The third argument describes what happens on unwind. It can be one of:
346+
/// - [`UnwindContinue`]
347+
/// - [`UnwindUnreachable`]
348+
/// - [`UnwindTerminate`]
349+
/// - [`UnwindCleanup`]
350+
fn Call(call: (), goto: ReturnToArg, unwind_action: UnwindActionArg)
351+
);
319352
define!("mir_unwind_resume",
320353
/// A terminator that resumes the unwinding.
321354
fn UnwindResume()

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs

+1-1
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()

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_after.rs

+1-1
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.

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.none.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.rs

+1-1
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()

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.stack.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.tree.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.none.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.rs

+1-1
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 = {

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.stack.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing.tree.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.rs

+1-1
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 = {

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.stack.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.tree.stderr

+2-2
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

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.rs

+2-2
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 = {

src/tools/miri/tests/fail/validity/cast_fn_ptr_invalid_caller_arg.rs

+1-1
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()

src/tools/miri/tests/fail/validity/cast_fn_ptr_invalid_caller_arg.stderr

+2-2
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

src/tools/miri/tests/pass/function_calls/return_place_on_heap.rs

+1-1
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 = {

tests/mir-opt/building/custom/terminators.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn ident<T>(t: T) -> T {
1313
fn direct_call(x: i32) -> i32 {
1414
mir!(
1515
{
16-
Call(RET = ident(x), retblock, UnwindContinue())
16+
Call(RET = ident(x), ReturnTo(retblock), UnwindContinue())
1717
}
1818

1919
retblock = {
@@ -27,7 +27,7 @@ fn direct_call(x: i32) -> i32 {
2727
fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 {
2828
mir!(
2929
{
30-
Call(RET = f(x), retblock, UnwindContinue())
30+
Call(RET = f(x), ReturnTo(retblock), UnwindContinue())
3131
}
3232

3333
retblock = {
@@ -49,7 +49,7 @@ impl<'a> Drop for WriteOnDrop<'a> {
4949
fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
5050
mir!(
5151
{
52-
Drop(a, retblock, UnwindContinue())
52+
Drop(a, ReturnTo(retblock), UnwindContinue())
5353
}
5454

5555
retblock = {
@@ -64,7 +64,7 @@ fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
6464
fn drop_second<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
6565
mir!(
6666
{
67-
Drop(b, retblock, UnwindContinue())
67+
Drop(b, ReturnTo(retblock), UnwindContinue())
6868
}
6969

7070
retblock = {

0 commit comments

Comments
 (0)