Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0cacf70
Merge link_name and export_name
bjorn3 Aug 15, 2025
7f2c8c6
Auto merge of #145478 - weihanglo:update-cargo, r=weihanglo
bors Aug 18, 2025
4aa1112
interpret: fix in-place return place semantics when the return place …
RalfJung Aug 18, 2025
e8fd761
Auto merge of #145489 - joshtriplett:cfg-if-not, r=Amanieu
bors Aug 18, 2025
68a0c7c
Add tracing to various miscellaneous functions
Stypox Aug 12, 2025
f9b6d4b
miri: detect passing the same local twice as an in-place argument
RalfJung Aug 18, 2025
09df8c7
Auto merge of #142487 - estebank:serde-attr-5, r=petrochenkov
bors Aug 19, 2025
7e4faad
Rollup merge of #139345 - smoelius:into-iter-stability, r=lcnr
jieyouxu Aug 19, 2025
ca934ab
Rollup merge of #142938 - lolbinarycat:std-set_permissions_nofollow, …
jieyouxu Aug 19, 2025
37865f8
Rollup merge of #143730 - pascaldekloe:fmt-radix-trim, r=tgross35
jieyouxu Aug 19, 2025
df57c77
Rollup merge of #144767 - tgross35:doc-grammar, r=ibraheemdev
jieyouxu Aug 19, 2025
3a8a9b5
Rollup merge of #144906 - Kobzol:infra-team-tier-bump, r=davidtwco
jieyouxu Aug 19, 2025
73d3033
Rollup merge of #144983 - Oneirical:uncountable-integer, r=jieyouxu
jieyouxu Aug 19, 2025
aba9e93
Rollup merge of #145025 - lolbinarycat:ci-tidy-spellcheck, r=Kobzol
jieyouxu Aug 19, 2025
0122d8b
Rollup merge of #145099 - heiher:loong-32s, r=folkertdev
jieyouxu Aug 19, 2025
441cc2b
Rollup merge of #145166 - makai410:teach-pub-crate, r=lcnr
jieyouxu Aug 19, 2025
0ab57e7
Rollup merge of #145255 - lune-climate:dec2flt-doc, r=ibraheemdev
jieyouxu Aug 19, 2025
9ddc0f0
Rollup merge of #145306 - Stypox:tracing-misc, r=RalfJung
jieyouxu Aug 19, 2025
5a2ef94
Rollup merge of #145336 - clarfonthey:hidden-unicode, r=ibraheemdev
jieyouxu Aug 19, 2025
d58b7b9
Rollup merge of #145585 - RalfJung:miri-inplace-arg-checks, r=compile…
jieyouxu Aug 19, 2025
05b7b68
Rollup merge of #145338 - lcnr:coroutine-witness-yikes, r=compiler-er…
jieyouxu Aug 19, 2025
bcfd908
Rollup merge of #145429 - bjorn3:codegen_fn_attrs_improvements, r=jdo…
jieyouxu Aug 19, 2025
b812411
Rollup merge of #145452 - Kobzol:bootstrap-strip, r=jieyouxu
jieyouxu Aug 19, 2025
2c06227
Rollup merge of #145464 - Kivooeo:stabilize-const_pathbuf_osstring_ne…
jieyouxu Aug 19, 2025
2d99185
Rollup merge of #145474 - fmease:paren-use-bounds-fix, r=fee1-dead
jieyouxu Aug 19, 2025
a17c625
Rollup merge of #145486 - Urgau:unicode-mention, r=lqd
jieyouxu Aug 19, 2025
01daf32
Rollup merge of #145490 - Kobzol:bootstrap-io-tracing, r=jieyouxu
jieyouxu Aug 19, 2025
75e5214
Rollup merge of #145493 - fee1-dead-contrib:push-rsqlqymxyyqp, r=jdon…
jieyouxu Aug 19, 2025
401cab1
Rollup merge of #145500 - JonathanBrouwer:must_use_target, r=jdonszel…
jieyouxu Aug 19, 2025
c5f61e0
Rollup merge of #145505 - cjgillot:tweak-span-cache, r=petrochenkov
jieyouxu Aug 19, 2025
be9163f
Rollup merge of #145510 - cjgillot:visit-async-drop, r=davidtwco
jieyouxu Aug 19, 2025
c83a99d
Rollup merge of #145511 - semarie:push-rnytptsoxrxn, r=joshtriplett
jieyouxu Aug 19, 2025
fd521c1
Rollup merge of #145532 - bvanjoi:debug-resolve-module, r=petrochenkov
jieyouxu Aug 19, 2025
a710161
Rollup merge of #145533 - smoelius:patch-2, r=lqd
jieyouxu Aug 19, 2025
3a6215d
Rollup merge of #145537 - zachs18:metasized-negative-bound-fix, r=dav…
jieyouxu Aug 19, 2025
a24d6f5
Rollup merge of #145568 - fee1-dead-contrib:push-uvsonuzxmkus, r=fmease
jieyouxu Aug 19, 2025
a3732c9
Rollup merge of #145571 - davidtwco:davidtwco-remove-from-groups, r=lqd
jieyouxu Aug 19, 2025
6ea3298
Rollup merge of #145578 - vexide:armv7a-vex-v5+linked-files, r=davidtwco
jieyouxu Aug 19, 2025
ce946a6
Auto merge of #145599 - jieyouxu:rollup-523cxhm, r=jieyouxu
bors Aug 19, 2025
38d9591
Auto merge of #145600 - jieyouxu:rollup-jw0bpnt, r=jieyouxu
bors Aug 19, 2025
c69d274
Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxu
bors Aug 19, 2025
7ba45da
Prepare for merging from rust-lang/rust
Aug 20, 2025
d1ac52c
Merge ref 'f605b57042ff' from rust-lang/rust
Aug 20, 2025
0c87adb
add back cfg(bootstrap), it is still needed
RalfJung Aug 20, 2025
9540ad2
bless new tests
RalfJung Aug 20, 2025
2059071
allow cfg(bootstrap)
RalfJung Aug 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ native-lib = ["dep:libffi", "dep:libloading", "dep:capstone", "dep:ipc-channel",

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(bootstrap)']

# Be aware that this file is inside a workspace when used via the
# submodule in the rustc repo. That means there are many cargo features
Expand Down
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
425a9c0a0e365c0b8c6cfd00c2ded83a73bed9a0
f605b57042ffeb320d7ae44490113a827139b766
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(bootstrap, feature(strict_overflow_ops))]
#![feature(abort_unwind)]
#![feature(cfg_select)]
#![feature(rustc_private)]
Expand Down
2 changes: 2 additions & 0 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
// For foreign items, try to see if we can emulate them.
if ecx.tcx.is_foreign_item(instance.def_id()) {
let _trace = enter_trace_span!("emulate_foreign_item");
// An external function call that does not have a MIR body. We either find MIR elsewhere
// or emulate its effect.
// This will be Ok(None) if we're emulating the intrinsic entirely within Miri (no need
Expand All @@ -1123,6 +1124,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
}

// Otherwise, load the MIR.
let _trace = enter_trace_span!("load_mir");
interp_ok(Some((ecx.load_mir(instance.def, None)?, instance)))
}

Expand Down
2 changes: 1 addition & 1 deletion src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
return interp_ok(());
}
// Skip over items without an explicitly defined symbol name.
if !(attrs.export_name.is_some()
if !(attrs.symbol_name.is_some()
|| attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE)
|| attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL))
{
Expand Down
34 changes: 34 additions & 0 deletions tests/fail/function_calls/arg_inplace_locals_alias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
// Validation forces more things into memory, which we can't have here.
//@compile-flags: -Zmiri-disable-validation
#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;

pub struct S(i32);

#[custom_mir(dialect = "runtime", phase = "optimized")]
fn main() {
mir! {
let _unit: ();
{
let staging = S(42); // This forces `staging` into memory...
let non_copy = staging; // ... so we move it to a non-inmemory local here.
// This specifically uses a type with scalar representation to tempt Miri to use the
// efficient way of storing local variables (outside adressable memory).
Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
//~[stack]^ ERROR: not granting access
//~[tree]| ERROR: /read access .* forbidden/
}
after_call = {
Return()
}
}
}

pub fn callee(x: S, mut y: S) {
// With the setup above, if `x` and `y` are both moved,
// then writing to `y` will change the value stored in `x`!
y.0 = 0;
assert_eq!(x.0, 42);
}
25 changes: 25 additions & 0 deletions tests/fail/function_calls/arg_inplace_locals_alias.stack.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <TAG> was created here, as the root tag for ALLOC
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <TAG> is this argument
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | y.0 = 0;
| ^^^^^^^
= note: BACKTRACE (of the first span):
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC

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

error: aborting due to 1 previous error

34 changes: 34 additions & 0 deletions tests/fail/function_calls/arg_inplace_locals_alias.tree.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
error: Undefined Behavior: read access through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
= help: the accessed tag <TAG> (root of the allocation) is foreign to the protected tag <TAG> (i.e., it is not a child)
= help: this foreign read access would cause the protected tag <TAG> (currently Active) to become Disabled
= help: protected tags must never be Disabled
help: the accessed tag <TAG> was created here
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: the protected tag <TAG> was created here, in the initial state Reserved
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | y.0 = 0;
| ^^^^^^^
help: the protected tag <TAG> later transitioned to Active due to a child write access at offsets [0x0..0x4]
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
|
LL | y.0 = 0;
| ^^^^^^^
= help: this transition corresponds to the first write to a 2-phase borrowed mutable reference
= note: BACKTRACE (of the first span):
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC

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

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ LL | unsafe { ptr.read() };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
ALLOC (stack variable, size: 4, align: 4) {
Expand Down
8 changes: 4 additions & 4 deletions tests/fail/function_calls/return_pointer_aliasing_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use std::intrinsics::mir::*;
pub fn main() {
mir! {
{
let x = 0;
let ptr = &raw mut x;
let _x = 0;
let ptr = &raw mut _x;
// We arrange for `myfun` to have a pointer that aliases
// its return place. Even just reading from that pointer is UB.
Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
}

after_call = {
Expand All @@ -25,7 +25,7 @@ pub fn main() {

fn myfun(ptr: *mut i32) -> i32 {
unsafe { ptr.read() };
//~[stack]^ ERROR: not granting access
//~[stack]^ ERROR: does not exist in the borrow stack
//~[tree]| ERROR: /read access .* forbidden/
//~[none]| ERROR: uninitialized
// Without an aliasing model, reads are "fine" but at least they return uninit data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
error: Undefined Behavior: attempting a read access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
LL | unsafe { ptr.read() };
| ^^^^^^^^^^ Undefined Behavior occurred here
| ^^^^^^^^^^ this error occurs as part of an access at ALLOC[0x0..0x4]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
Expand All @@ -11,12 +11,12 @@ help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
|
LL | / mir! {
LL | | {
LL | | let x = 0;
LL | | let ptr = &raw mut x;
LL | | let _x = 0;
LL | | let ptr = &raw mut _x;
... |
LL | | }
| |_____^
help: <TAG> is this argument
help: <TAG> was later invalidated at offsets [0x0..0x4] by a Unique in-place function argument/return passing protection
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
LL | unsafe { ptr.read() };
Expand All @@ -26,8 +26,8 @@ LL | unsafe { ptr.read() };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ help: the accessed tag <TAG> was created here
|
LL | / mir! {
LL | | {
LL | | let x = 0;
LL | | let ptr = &raw mut x;
LL | | let _x = 0;
LL | | let ptr = &raw mut _x;
... |
LL | | }
| |_____^
Expand All @@ -35,8 +35,8 @@ LL | unsafe { ptr.read() };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Expand Down
4 changes: 2 additions & 2 deletions tests/fail/function_calls/return_pointer_aliasing_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn main() {
let ptr = &raw mut _x;
// We arrange for `myfun` to have a pointer that aliases
// its return place. Writing to that pointer is UB.
Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
}

after_call = {
Expand All @@ -26,7 +26,7 @@ pub fn main() {
fn myfun(ptr: *mut i32) -> i32 {
// This overwrites the return place, which shouldn't be possible through another pointer.
unsafe { ptr.write(0) };
//~[stack]^ ERROR: strongly protected
//~[stack]^ ERROR: does not exist in the borrow stack
//~[tree]| ERROR: /write access .* forbidden/
13
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
error: Undefined Behavior: attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
--> tests/fail/function_calls/return_pointer_aliasing_write.rs:LL:CC
|
LL | unsafe { ptr.write(0) };
| ^^^^^^^^^^^^ Undefined Behavior occurred here
| ^^^^^^^^^^^^ this error occurs as part of an access at ALLOC[0x0..0x4]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
Expand All @@ -16,7 +16,7 @@ LL | | let ptr = &raw mut _x;
... |
LL | | }
| |_____^
help: <TAG> is this argument
help: <TAG> was later invalidated at offsets [0x0..0x4] by a Unique in-place function argument/return passing protection
--> tests/fail/function_calls/return_pointer_aliasing_write.rs:LL:CC
|
LL | unsafe { ptr.write(0) };
Expand All @@ -26,8 +26,8 @@ LL | unsafe { ptr.write(0) };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_write.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ LL | unsafe { ptr.write(0) };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_write.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn main() {
let ptr = &raw mut _x;
// We arrange for `myfun` to have a pointer that aliases
// its return place. Writing to that pointer is UB.
Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
}

after_call = {
Expand All @@ -32,7 +32,7 @@ fn myfun(ptr: *mut i32) -> i32 {
fn myfun2(ptr: *mut i32) -> i32 {
// This overwrites the return place, which shouldn't be possible through another pointer.
unsafe { ptr.write(0) };
//~[stack]^ ERROR: strongly protected
//~[stack]^ ERROR: does not exist in the borrow stack
//~[tree]| ERROR: /write access .* forbidden/
13
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
error: Undefined Behavior: attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
--> tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs:LL:CC
|
LL | unsafe { ptr.write(0) };
| ^^^^^^^^^^^^ Undefined Behavior occurred here
| ^^^^^^^^^^^^ this error occurs as part of an access at ALLOC[0x0..0x4]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
Expand All @@ -16,18 +16,18 @@ LL | | let ptr = &raw mut _x;
... |
LL | | }
| |_____^
help: <TAG> is this argument
help: <TAG> was later invalidated at offsets [0x0..0x4] by a Unique in-place function argument/return passing protection
--> tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs:LL:CC
|
LL | unsafe { ptr.write(0) };
| ^^^^^^^^^^^^^^^^^^^^^^^
LL | become myfun2(ptr)
| ^^^^^^^^^^^^^^^^^^
= note: BACKTRACE (of the first span):
= note: inside `myfun2` at tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs:LL:CC
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ LL | unsafe { ptr.write(0) };
note: inside `main`
--> tests/fail/function_calls/return_pointer_aliasing_write_tail_call.rs:LL:CC
|
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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)

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