Skip to content

Commit 980da67

Browse files
authored
Merge pull request #4532 from rust-lang/rustup-2025-08-20
Automatic Rustup
2 parents 3156c9e + 2059071 commit 980da67

18 files changed

+136
-39
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ native-lib = ["dep:libffi", "dep:libloading", "dep:capstone", "dep:ipc-channel",
7878

7979
[lints.rust.unexpected_cfgs]
8080
level = "warn"
81+
check-cfg = ['cfg(bootstrap)']
8182

8283
# Be aware that this file is inside a workspace when used via the
8384
# submodule in the rustc repo. That means there are many cargo features

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
425a9c0a0e365c0b8c6cfd00c2ded83a73bed9a0
1+
f605b57042ffeb320d7ae44490113a827139b766

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(bootstrap, feature(strict_overflow_ops))]
12
#![feature(abort_unwind)]
23
#![feature(cfg_select)]
34
#![feature(rustc_private)]

src/machine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11111111
) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> {
11121112
// For foreign items, try to see if we can emulate them.
11131113
if ecx.tcx.is_foreign_item(instance.def_id()) {
1114+
let _trace = enter_trace_span!("emulate_foreign_item");
11141115
// An external function call that does not have a MIR body. We either find MIR elsewhere
11151116
// or emulate its effect.
11161117
// This will be Ok(None) if we're emulating the intrinsic entirely within Miri (no need
@@ -1123,6 +1124,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11231124
}
11241125

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

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
153153
return interp_ok(());
154154
}
155155
// Skip over items without an explicitly defined symbol name.
156-
if !(attrs.export_name.is_some()
156+
if !(attrs.symbol_name.is_some()
157157
|| attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE)
158158
|| attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL))
159159
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//@revisions: stack tree
2+
//@[tree]compile-flags: -Zmiri-tree-borrows
3+
// Validation forces more things into memory, which we can't have here.
4+
//@compile-flags: -Zmiri-disable-validation
5+
#![feature(custom_mir, core_intrinsics)]
6+
use std::intrinsics::mir::*;
7+
8+
pub struct S(i32);
9+
10+
#[custom_mir(dialect = "runtime", phase = "optimized")]
11+
fn main() {
12+
mir! {
13+
let _unit: ();
14+
{
15+
let staging = S(42); // This forces `staging` into memory...
16+
let non_copy = staging; // ... so we move it to a non-inmemory local here.
17+
// This specifically uses a type with scalar representation to tempt Miri to use the
18+
// efficient way of storing local variables (outside adressable memory).
19+
Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
20+
//~[stack]^ ERROR: not granting access
21+
//~[tree]| ERROR: /read access .* forbidden/
22+
}
23+
after_call = {
24+
Return()
25+
}
26+
}
27+
}
28+
29+
pub fn callee(x: S, mut y: S) {
30+
// With the setup above, if `x` and `y` are both moved,
31+
// then writing to `y` will change the value stored in `x`!
32+
y.0 = 0;
33+
assert_eq!(x.0, 42);
34+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
2+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
3+
|
4+
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
8+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
9+
help: <TAG> was created here, as the root tag for ALLOC
10+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
11+
|
12+
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
help: <TAG> is this argument
15+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
16+
|
17+
LL | y.0 = 0;
18+
| ^^^^^^^
19+
= note: BACKTRACE (of the first span):
20+
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
21+
22+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
23+
24+
error: aborting due to 1 previous error
25+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: Undefined Behavior: read access through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
2+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
3+
|
4+
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
9+
= help: the accessed tag <TAG> (root of the allocation) is foreign to the protected tag <TAG> (i.e., it is not a child)
10+
= help: this foreign read access would cause the protected tag <TAG> (currently Active) to become Disabled
11+
= help: protected tags must never be Disabled
12+
help: the accessed tag <TAG> was created here
13+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
14+
|
15+
LL | Call(_unit = callee(Move(non_copy), Move(non_copy)), ReturnTo(after_call), UnwindContinue())
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
help: the protected tag <TAG> was created here, in the initial state Reserved
18+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
19+
|
20+
LL | y.0 = 0;
21+
| ^^^^^^^
22+
help: the protected tag <TAG> later transitioned to Active due to a child write access at offsets [0x0..0x4]
23+
--> tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
24+
|
25+
LL | y.0 = 0;
26+
| ^^^^^^^
27+
= help: this transition corresponds to the first write to a 2-phase borrowed mutable reference
28+
= note: BACKTRACE (of the first span):
29+
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias.rs:LL:CC
30+
31+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
32+
33+
error: aborting due to 1 previous error
34+

tests/fail/function_calls/return_pointer_aliasing_read.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
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
1313
|
14-
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

1717
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
1818
ALLOC (stack variable, size: 4, align: 4) {

tests/fail/function_calls/return_pointer_aliasing_read.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use std::intrinsics::mir::*;
1010
pub fn main() {
1111
mir! {
1212
{
13-
let x = 0;
14-
let ptr = &raw mut x;
13+
let _x = 0;
14+
let ptr = &raw mut _x;
1515
// We arrange for `myfun` to have a pointer that aliases
1616
// its return place. Even just reading from that pointer is UB.
17-
Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
17+
Call(_x = myfun(ptr), ReturnTo(after_call), UnwindContinue())
1818
}
1919

2020
after_call = {
@@ -25,7 +25,7 @@ pub fn main() {
2525

2626
fn myfun(ptr: *mut i32) -> i32 {
2727
unsafe { ptr.read() };
28-
//~[stack]^ ERROR: not granting access
28+
//~[stack]^ ERROR: does not exist in the borrow stack
2929
//~[tree]| ERROR: /read access .* forbidden/
3030
//~[none]| ERROR: uninitialized
3131
// Without an aliasing model, reads are "fine" but at least they return uninit data.

0 commit comments

Comments
 (0)