Skip to content

Rollup of 12 pull requests - #160339

Merged
rust-bors[bot] merged 31 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ogANt9s
Aug 1, 2026
Merged

Rollup of 12 pull requests#160339
rust-bors[bot] merged 31 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ogANt9s

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Successful merges:

r? @ghost

Create a similar rollup

RalfJung and others added 30 commits July 18, 2026 10:33
Co-authored-by: Jacob Lifshay <programmerjake@gmail.com>
This updates the crate to a version where the imported APIs use
officially released/defined versions of interfaces. For the
`wasm32-wasip3` target this is WASI 0.3.0. Note that `wasm32-wasip3` is
still a tier 3 target, so this isn't expected to have much practical
effect until it's upgraded to tier 2.
When we suggest implementing a missing trait item (or group of items
from `must_implement_one_of`), label any unstable items, so the user
doesn't get confused by suggestions to implement an unstable item
parallel to suggestions to implement stable items.
Includes a test for unstable trait methods.
…null`

* replace unsafe usage of `NonNull::new_unchecked` with `NonNull::from_mut`
* apply review feedback
* apply review feedback again!
Adding noundef to a PassMode::Cast is only sound when the cast target covers no
more bytes than the layout, otherwise the extra register bytes are undef padding.
In adjust_for_rust_abi this holds by construction (the cast is sized to
layout.size), so the current layout_is_noundef-only check is correct but relies
on that implicitly.

Extract the decision into ArgAbi::cast_to_maybe_noundef, which forwards NoUndef
only when layout_is_noundef(layout) && cast.size == layout.size, and switch the
aggregate-immediate site to it. No behavior change.
This check is now done from `finalise_check` in the attribute parser by
emitting `TrackCallerOnLangItem`. This replaces `check_track_caller` in
`rust_passes`.
stabilize size_of_val_raw, align_of_val_raw, Layout::for_value_raw

Stabilizes versions of `size_of_val_raw` and friends that can be invoked on raw pointers, which means they can be used even if one does not have a pointer to a "valid value". This was held up for a while because figuring out the exact safety requirements is tricky, but I think the ones we now have had for a while (plus the minor clarifications in this PR) are "good enough": we basically do case distinction on the unsized tail of the type, and spell out the appropriate requirement for each case. This avoids making blanket statements about future kinds of DST that we may introduce eventually.

These are the requirements I should we should stabilize:

```
    /// - If `T` is `Sized`, this function is always safe to call.
    /// - If the unsized tail of `T` is:
    ///     - a [slice] `[U]`, `str`, or a [trait object] `dyn Trait`, then the size of the *entire value*
    ///       (dynamic tail length + statically sized prefix) must fit in `isize`.
    ///       For the special case where the dynamic tail length is 0, this function
    ///       is safe to call.
    //        NOTE: the reason this is safe is that if an overflow were to occur already with size 0,
    //        then we would stop compilation as even the "statically known" part of the type would
    //        already be too big (or the call may be in dead code and optimized away, but then it
    //        doesn't matter).
    ///     - No other kind of unsized tail currently exists that satisfies the trait bounds for this
    ///       function. If more kinds of unsized tails get introduced in the future, the documentation
    ///       of this function will have to be extended before it can be used for such types.
```

Going over the open questions from the [tracking issue](rust-lang#69835):
-  What should the exact safety requirements of these functions be? -> the currently documented requirement look good to me.
- How should this interact with extern types? -> what we document looks good here; we can still adjust this until extern types are stabilized.
- Are the functions sound to call on invalid data pointers? -> for the unsized tails that currently exist: yes; that's kind of the only reason to use them.

Cc @rust-lang/opsem @rust-lang/lang
(FCP should probably include both teams, unless lang is okay with fully delegating this to t-opsem)
I'll nominate the tracking issue for libs-api so we can get their approval as well for how the operation is exposed.

Fixes rust-lang#69835
miri: ensure validity of references and pointers we dereference and cast

Conceptually, when we evaluate the place expression `*place`, there are two steps that happen:
- perform a (typed) load from `place`, which yields a value of pointer/ref type
- construct a new place from that value

Since this is a typed load, we have to ensure that the value satisfies the validity invariant. We forgot to do that, which led to Miri missing a bunch of UB. This PR fixes that by adding the missing checks.

Triggering this UB is a bit non-trivial: you cannot just store an invalid value into `place` using regular assignment (that would already be caught as part of the assignment). However, you can take a raw pointer to `place` and then use that to mutate the contents of `place` in a way that its validity invariant no longer holds. For example:
```rust
fn main() {
    let mut x = &();
    // Overwrite `x` with null.
    unsafe { (&raw mut x).cast::<usize>().write(0) };
    let _val = *x; //~ERROR: null reference
}
```
This program clearly (IMO) should have UB, and has UB in MiniRust, but Miri accepted that program before this PR. The same applies to references that are invalid because they are unaligned (even if we end up only accessing a 1-aligned field, i.e. the rest of the place expression evaluates just fine), and to references that are invalid because they are not dereferenceable (even if we end up projecting to a zero-sized field, i.e., the rest of the place expression evaluates just fine).

Even raw pointers have this problem: a raw pointer can be invalid if its vtable pointer is wrong, and we did not check that.

And finally, this also affects `Box`, and this is where things get tricky. `Box` derefs are not even present any more in the MIR Miri sees; they have been replaced by derefs of the underlying raw pointer. But that means we have no way to know that we should check all those things. So to fix that I adjusted the ElaborateBoxDerefs to emit a new special kind of cast that's almost a transmute but also checks `Box` validity.

Fixes rust-lang/miri#5226
Fixes rust-lang/unsafe-code-guidelines#617
Cc @rust-lang/opsem
…eyouxu

Update Enzyme to resolve one of the open bugs
…acrum

allocations: document that they can be read-only

Miri currently tracks "read-only" as an explicit flag on allocations that exists independent of provenance. It essentially corresponds to a read-only mapping in the page table.

Let's make this officially part of our model.
Cc @rust-lang/lang @rust-lang/opsem
…joboet

std: Update `wasip3` crate dependency

This updates the crate to a version where the imported APIs use officially released/defined versions of interfaces. For the `wasm32-wasip3` target this is WASI 0.3.0. Note that `wasm32-wasip3` is still a tier 3 target, so this isn't expected to have much practical effect until it's upgraded to tier 2.
…-no-unstable-suggestions, r=JohnTitor

When issuing suggestions for missing trait items, label unstable items

When we suggest implementing a missing trait item (or group of items from `must_implement_one_of`), label any unstable items, so the user doesn't get confused by suggestions to implement an unstable item parallel to suggestions to implement stable items.
…=jhpratt,RalfJung

Replace unsafe usage of `NonNull::new_unchecked` with `Box::into_non_null`

~~We can avoid unsafe by replacing `unsafe { NonNull::new_unchecked(Box::into_raw(..)) }` with `NonNull::from_mut(Self::leak(..))`. A simple test to demonstrate the code generation is equivalent: https://godbolt.org/z/P5q9bzPPK~~

We can avoid unsafe by replacing `unsafe { NonNull::new_unchecked(Box::into_raw(..)) }` with the (soon-to-be-stable) `Box::into_non_null(..)`

Additionally, slightly tweak documentation.
Remove final use of sealed traits from stdlib

Now that stdarch has been updated, this vestigial trait is no longer needed. Since I last touched this, there was one additional usage of it added. This has been removed in favor of the native `impl(self)` syntax.

r? libs
…-guard, r=RalfJung

Make the noundef-on-Cast size guard explicit

`ArgAbi::cast_to` drops the argument's `ArgAttributes`. rust-lang#152864 restored `noundef` on `PassMode::Cast` for the Rust ABI by re-adding it via `cast_to_with_attrs` when `layout_is_noundef` is true.

This works today because `adjust_for_rust_abi` constructs a `Reg { Integer, size }` with `size == layout.size`. However, this assumption isn't guarded anywhere - if this pattern gets reused where a cast is wider than the layout (like foreign ABIs using `Uniform::new` rounding up), padding bytes would be incorrectly marked as `noundef`.

This PR adds an explicit size check via a new `ArgAbi::cast_to_maybe_noundef` helper, which only emits `NoUndef` if `layout_is_noundef(layout)` and `cast.size(cx) <= layout.size`.

No functional change intended. Existing tests (like `abi-noundef-cast`) continue to pass.

Split out from the foreign-ABI work per the Zulip thread; foreign `Reg::iN` sites will reuse this helper in a follow-up PR.

r? @RalfJung
Box::leak: tell people to avoid unleaking

r? @nia-e
Cc @rust-lang/opsem

Note that this goes against the advice given by clippy in rust-lang/rust-clippy#17336. I think clippy should be adjusted to recommend `Box::into_non_null` instead. @ArhanChaudhary wold be great if you could make a clippy PR for that. :)
…to_attribute_parser, r=JonathanBrouwer

Move `check_track_caller` into the attribute parser

cc rust-lang#153101
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 1, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

@bors r+ rollup=never p=5

Trying commonly failed jobs
@bors try jobs=dist-various-1,test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1,i686-msvc-*

@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3a91391 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 1, 2026
Rollup of 12 pull requests


try-job: dist-various-1
try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
try-job: i686-msvc-*
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a9988f2 (a9988f2ada7ed9fed77a540e7583b2c4ac8db631)
Base parent: c47bb2f (c47bb2f39658c00b109693df9611d7238bedf6fa)

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 1, 2026
@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: JonathanBrouwer
Duration: 3h 17m 26s
Pushing b430378 to main...

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing c47bb2f (parent) -> b430378 (this PR)

Test differences

Show 505 test diffs

Stage 1

  • [ui] tests/ui/traits/default-method/rustc_must_implement_one_of-unstable.rs: [missing] -> pass (J0)
  • [ui (polonius)] tests/ui/traits/default-method/rustc_must_implement_one_of-unstable.rs: [missing] -> pass (J2)

Stage 2

  • [ui] tests/ui/traits/default-method/rustc_must_implement_one_of-unstable.rs: [missing] -> pass (J1)

Additionally, 502 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard b430378746a835fd5240e2c7169795d7de0547e8 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc-core-tests: 7m 20s -> 14m 2s (+91.1%)
  2. x86_64-msvc-ext1: 1h 24m -> 2h 19m (+65.6%)
  3. optional-x86_64-gnu-autodiff: 36m 36s -> 50m 2s (+36.7%)
  4. i686-gnu-nopt-2: 1h 40m -> 2h 16m (+36.4%)
  5. dist-x86_64-msvc-alt: 2h 59m -> 1h 56m (-35.2%)
  6. dist-android: 21m 25s -> 28m 49s (+34.5%)
  7. x86_64-msvc-1: 2h 48m -> 1h 57m (-30.5%)
  8. i686-msvc-2: 2h 11m -> 1h 32m (-29.9%)
  9. i686-gnu-1: 1h 53m -> 2h 20m (+23.8%)
  10. dist-apple-various: 1h 37m -> 1h 59m (+23.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#157572 stabilize size_of_val_raw, align_of_val_raw, Layout::for_va… 16575e7e5cf3ba75d0eb396f9ab059cb46e0d451 (link)
#160012 miri: ensure validity of references and pointers we derefer… fe46b756b24b918b6a7ac28df3f6aca090573611 (link)
#160294 Update Enzyme to resolve one of the open bugs d3fe80353128a360b6f3369968ccbc7cd9eb6898 (link)
#159503 allocations: document that they can be read-only 5d6f7d54b0e16960b6d062cad20b7a641e826f87 (link)
#160179 std: Update wasip3 crate dependency ae6e2f87b808606462f4e2df45a5f3bf0f8d452f (link)
#160250 When issuing suggestions for missing trait items, label uns… c4f935395b8ab2c8b772152fe3c1ad29ed6888ed (link)
#160251 Replace unsafe usage of NonNull::new_unchecked with `Box:… cbab7fd7bde80b2a59dc3ffcd0e9cb0122b21b67 (link)
#160311 Remove final use of sealed traits from stdlib efc2db75c250749e98c4eb8735d84548a19071e0 (link)
#160313 Make the noundef-on-Cast size guard explicit 831daa11523195f7bd63a75f362df77455992b9b (link)
#160323 Box::leak: tell people to avoid unleaking 2350676d99338c05aaaefe91346e854ec2bfd225 (link)
#160328 Move check_track_caller into the attribute parser fce43b3d629e0e1253e72325a39d39d8fde95809 (link)
#160333 Remove itertools dependency from rustc_ast_pretty a0632a7168209e6a6201f4dc582df3de47958f2d (link)

previous master: c47bb2f396

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b430378): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
15.8% [14.6%, 17.3%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.2%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.2%, secondary 1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
1.1% [1.1%, 1.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.2% [2.2%, 2.2%] 1

Cycles

Results (primary 0.3%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.8% [0.4%, 1.5%] 8
Regressions ❌
(secondary)
1.6% [0.7%, 2.7%] 7
Improvements ✅
(primary)
-0.7% [-1.1%, -0.5%] 4
Improvements ✅
(secondary)
-2.0% [-7.1%, -0.5%] 6
All ❌✅ (primary) 0.3% [-1.1%, 1.5%] 12

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 490.834s -> 489.711s (-0.23%)
Artifact size: 390.52 MiB -> 390.35 MiB (-0.04%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) F-autodiff `#![feature(autodiff)]` merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. rollup A PR which is a rollup T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.