Skip to content

Merge subtree update for toolchain nightly-2025-08-07 #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10,000 commits into
base: main
Choose a base branch
from

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Aug 8, 2025

This is an automated PR to merge library subtree updates from 2025-08-06 (rust-lang/rust@ec7c026) to 2025-08-07 (rust-lang/rust@7d82b83), inclusive. This is a clean merge, no conflicts were detected. Do not remove or edit the following annotations:
git-subtree-dir: library
git-subtree-split: 4ff8a80

nik-rev and others added 30 commits July 13, 2025 23:24
These seem like they were missed in <rust-lang#141224>
…t, r=compiler-errors

update issue number for `const_trait_impl`

r? project-const-traits

cc rust-lang#67792 rust-lang#143874
Use zero for initialized Once state

By re-labeling which integer represents which internal state for `Once` we can ensure that the initialized state is the all-zero state. This is beneficial because some CPU architectures (such as Arm) have specialized instructions to specifically branch on non-zero, and checking for the initialized state is by far the most important operation.

As an example, take this:

```rust
use std::sync::atomic::{AtomicU32, Ordering};

const INIT: u32 = 3;

#[inline(never)]
#[cold]
pub fn slow(state: &AtomicU32) {
    state.store(INIT, Ordering::Release);
}

pub fn ensure_init(state: &AtomicU32) {
    if state.load(Ordering::Acquire) != INIT {
        slow(state)
    }
}
```

If `INIT` is 3 (as is currently the state for `Once`), we see the following assembly on `aarch64-apple-darwin`:

```asm
example::ensure_init::h332061368366e313:
        ldapr   w8, [x0]
        cmp     w8, #3
        b.ne    LBB1_2
        ret
LBB1_2:
        b       example::slow::ha042bd6a4f33724e
```

By changing the `INIT` state to zero we get the following:

```asm
example::ensure_init::h332061368366e313:
        ldapr   w8, [x0]
        cbnz    w8, LBB1_2
        ret
LBB1_2:
        b       example::slow::ha042bd6a4f33724e
```

So this PR saves 1 instruction every time a `LazyLock` gets accessed on platforms such as these.
…-to-allocation, r=oli-obk

Change "allocated object" to "allocation".

These seem like they were missed in <rust-lang#141224>
Don't call WSACleanup on process exit

This isn't necessary as cleanup will happen when the process exits regardless.

fixes rust-lang#141799
…htriplett

Updates to random number generation APIs

Updates based on discussions about random number generation.

- Add comment on `RandomSource::fill_bytes` about multiple calls, to allow
  efficient implementations for random sources that generate a word at a time.

- Drop the `Random` trait in favor of `Distribution<T>`, which will let people
  make calls like random(1..=6), and which allows for future expansion to
  non-uniform distributions, as well as floating-point. (For now, this is only
  implemented for `RangeFull`, to get the interface in place. Subsequent PRs
  will implement it for other range types.)
and make internal terminology consistent

Co-authored-by: Travis Cross <[email protected]>
…test

`intrinsic-test`: use runner also for rust
Add rustc-pull CI automation workflow
`aarch64`: use more of `intrinsics::simd` for min/max
loongarch: Add basic support for LoongArch32
…intrinsic

`s390x`: document the different rounding flavors
…k-Simulacrum

core: Add `BorrowedCursor::with_unfilled_buf`

Implementation of rust-lang/libs-team#367.

This mainly adds `BorrowedCursor::with_unfilled_buf`, with enables using the unfilled part of a cursor as a `BorrowedBuf`.

Note that unlike the ACP, `BorrowedCursor::unfilled_buf` was moved to a `From` conversion. This is more consistent with other ways of creating a `BorrowedBuf` and hides a bit this conversion that requires unsafe code to be used correctly.

Cc rust-lang#78485 rust-lang#117693
`aarch64`: use `intrinsics::simd` for horizontal add and `abs`
…ked, r=Mark-Simulacrum

core: make `str::split_at_unchecked()` inline

This PR adds `#[inline]` to the method `str::split_at_unchecked()`. This is done for two reasons:

1. The method is tiny, e.g. on AMD-64 (<https://godbolt.org/z/ba68fdfxn>):

   ```asm
   movq    %rdi, %rax
   subq    %rcx, %rdx
   movq    %rsi, (%rdi)
   addq    %rcx, %rsi
   movq    %rcx, 8(%rdi)
   movq    %rsi, 16(%rdi)
   movq    %rdx, 24(%rdi)
   retq
   ```

2. More importantly, inlining the method enables further automatic optimizations. E.g. if you split at index 3, then in the compiler (rustc, llvm or both) knows that this code cannot fail, and the panicking path is omitted in the generated code:

   ```rust
   pub fn punctuation(i: &str) -> Result<(), ()> {
       const THREE_CHARS: &[[u8; 3]] = &[*b"<<=", *b">>=", *b"...", *b"..="];

       if let Some((head, _)) = i.split_at_checked(3)
           && THREE_CHARS.contains(&head.as_bytes().try_into().unwrap())
       {
           Ok(())
       } else {
           Err(())
       }
   }
   ```

   <details>
   <summary>Without PR</summary>

   <https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=0234de8158f467eebd73286f20d6e27a>

   ```asm
   playground::punctuation:
           subq    $40, %rsp
           movq    %rsi, %rdx
           movq    %rdi, %rsi
           movb    $1, %al
           cmpq    $3, %rdx
           ja      .LBB2_2
           je      .LBB2_3
   .LBB2_11:
           addq    $40, %rsp
           retq
   .LBB2_2:
           cmpb    $-64, 3(%rsi)
           jl      .LBB2_11
   .LBB2_3:
           leaq    8(%rsp), %rdi
           movl    $3, %ecx
           callq   *core::str::<impl str>::split_at_unchecked@GOTPCREL(%rip)
           movq    8(%rsp), %rcx
           movb    $1, %al
           testq   %rcx, %rcx
           je      .LBB2_11
           cmpq    $3, 16(%rsp)
           jne     .LBB2_12
           movzwl  (%rcx), %edx
           movzbl  2(%rcx), %ecx
           shll    $16, %ecx
           orl     %edx, %ecx
           cmpl    $4013115, %ecx
           jg      .LBB2_8
           cmpl    $3026478, %ecx
           je      .LBB2_10
           cmpl    $4009518, %ecx
           je      .LBB2_10
           jmp     .LBB2_11
   .LBB2_8:
           cmpl    $4013630, %ecx
           je      .LBB2_10
           cmpl    $4013116, %ecx
           jne     .LBB2_11
   .LBB2_10:
           xorl    %eax, %eax
           addq    $40, %rsp
           retq
   .LBB2_12:
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.2(%rip), %rdi
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.1(%rip), %rcx
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.6(%rip), %r8
           leaq    7(%rsp), %rdx
           movl    $43, %esi
           callq   *core::result::unwrap_failed@GOTPCREL(%rip)
   ```
   </details>

   <details>
   <summary>With PR</summary>

   <https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=5d4058c79ce0f6cb1a434190427d2055>

   ```asm
   playground::punctuation:
           movb    $1, %al
           cmpq    $3, %rsi
           ja      .LBB0_2
           je      .LBB0_3
   .LBB0_9:
           retq
   .LBB0_2:
           cmpb    $-64, 3(%rdi)
           jl      .LBB0_9
   .LBB0_3:
           movzwl  (%rdi), %eax
           movzbl  2(%rdi), %ecx
           shll    $16, %ecx
           orl     %eax, %ecx
           movb    $1, %al
           cmpl    $4013115, %ecx
           jg      .LBB0_6
           cmpl    $3026478, %ecx
           je      .LBB0_8
           cmpl    $4009518, %ecx
           je      .LBB0_8
           jmp     .LBB0_9
   .LBB0_6:
           cmpl    $4013630, %ecx
           je      .LBB0_8
           cmpl    $4013116, %ecx
           jne     .LBB0_9
   .LBB0_8:
           xorl    %eax, %eax
           retq
   ```
   </details>
…ross35

Add experimental `backtrace-trace-only` std feature

This experimentally allows building std with backtrace but without symbolisation. It does not affect stable and requires build-std to use. This doesn't change the backtrace crate itself so relies on the optimizer to remove the unused parts.

Example usage:

```toml
# .cargo/config.toml
[unstable]
build-std = ["core", "alloc", "panic_unwind", "std"]
build-std-features = ["backtrace", "backtrace-trace-only", "panic-unwind"]
```

```toml
# Cargo.toml
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1
```

Ideally we should split the backtrace feature into `backtrace-trace` and `backtrace-symbolize` (with the latter dependent on the former) because Cargo features tend to work better when they're positive rather than negative. But I'm keen for this experiment not to break existing users.

cc ``@joshtriplett``
…iscross

update `cfg_select!` documentation

tracking issue: rust-lang#115585

After rust-lang#143461, and with an eye on a soon(ish) stabilization, I think the docs need some work.

The existing text read more like a motivation for the feature existing to me, so I've tried to now be a bit more descriptive. Still, suggestions are very welcome.

I also added a test for an empty `select! {}` because it's just the sort of thing that might break.

r? ``@traviscross``
`std::vec`: Add UB check for `set_len`, `from_raw_parts_in`, and etc.

Closes rust-lang#143813

I noticed that `from_parts_in` do the similar things like `from_raw_parts_in`, so I add the UB check in the last commit. If it is not appropriate, I will remove it.

And I fix a typo in the first commit.

r? `@scottmcm`
samueltardieu and others added 29 commits August 2, 2025 11:24
…rep, r=Amanieu

Improve formatting of doc code blocks

We don't currently apply automatic formatting to doc comment code blocks. As a
result, it has built up various idiosyncracies, which make such automatic
formatting difficult. Some of those idiosyncracies also make things harder for
human readers or other tools.

This PR makes a few improvements to doc code formatting, in the hopes of making
future automatic formatting easier, as well as in many cases providing net
readability improvements.

I would suggest reading each commit separately, as each commit contains one
class of changes.
…Noratrieb

Update safety comment for new_unchecked in niche_types

Change the safety comment on `new_unchecked` to mention the valid range instead of 0. I noticed this while working on https://github.com/model-checking/verify-rust-std
Currently the Args new function is scope constrained to pub(super) but this stops me from being able to construct Args structs in unit tests.
compiler & tools dependencies:
     Locking 14 packages to latest compatible versions
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating jsonpath-rust v1.0.3 -> v1.0.4
    Updating libredox v0.1.6 -> v0.1.9
    Updating object v0.37.1 -> v0.37.2
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating redox_users v0.5.0 -> v0.5.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating serde_json v1.0.141 -> v1.0.142
    Updating wasm-encoder v0.235.0 -> v0.236.0
    Updating wasmparser v0.235.0 -> v0.236.0
    Updating wast v235.0.0 -> v236.0.0
    Updating wat v1.235.0 -> v1.236.0
    Updating windows-targets v0.53.2 -> v0.53.3
note: pass `--verbose` to see 36 unchanged dependencies behind latest

library dependencies:
     Locking 3 packages to latest compatible versions
    Updating object v0.37.1 -> v0.37.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating unwinding v0.2.7 -> v0.2.8
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 6 packages to latest compatible versions
    Updating cc v1.2.30 -> v1.2.31
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating serde_json v1.0.141 -> v1.0.142
    Updating windows-targets v0.53.2 -> v0.53.3
…Noratrieb

Implement `hash_map` macro

Implementation of rust-lang#144032

Implements the `hash_map` macro under `std/src/macros.rs`.
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.
r? dep-bumps

The following is the output from `cargo update`:

```txt

compiler & tools dependencies:
     Locking 14 packages to latest compatible versions
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating jsonpath-rust v1.0.3 -> v1.0.4
    Updating libredox v0.1.6 -> v0.1.9
    Updating object v0.37.1 -> v0.37.2
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating redox_users v0.5.0 -> v0.5.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating serde_json v1.0.141 -> v1.0.142
    Updating wasm-encoder v0.235.0 -> v0.236.0
    Updating wasmparser v0.235.0 -> v0.236.0
    Updating wast v235.0.0 -> v236.0.0
    Updating wat v1.235.0 -> v1.236.0
    Updating windows-targets v0.53.2 -> v0.53.3
note: pass `--verbose` to see 36 unchanged dependencies behind latest

library dependencies:
     Locking 3 packages to latest compatible versions
    Updating object v0.37.1 -> v0.37.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating unwinding v0.2.7 -> v0.2.8
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 6 packages to latest compatible versions
    Updating cc v1.2.30 -> v1.2.31
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating serde_json v1.0.141 -> v1.0.142
    Updating windows-targets v0.53.2 -> v0.53.3
```
…ce-impl, r=Mark-Simulacrum

Mark `slice::swap_with_slice` unstably const

Tracking issue rust-lang#142204
…, r=Mark-Simulacrum

`available_parallelism`: Add documentation for why we don't look at `ulimit`
…oss35

`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
…lacrum

Remove unnecessary `rust_` prefixes

part of rust-lang#116005

Honestly, not sure if this can affect linking somehow, also I didn't touched things like `__rust_panic_cleanup` and `__rust_start_panic` which very likely will break something, so just small cleanup here

also didn't changed `rust_panic_without_hook` because it was renamed here rust-lang#144852

r? libs
Rename `rust_panic_without_hook` to `resume_unwind`

part of rust-lang#116005

r? libs
Use `as_array` in PartialEq for arrays

Now that `as_array` exists we might as well use it here, since it's a bit more convenient than getting the correct type out of `try_into`.
…manieu

Document Poisoning in `LazyCell` and `LazyLock`

Currently, there is no documentation of poisoning behavior in either `LazyCell` or `LazyLock`, even though both of them can be observed as poisoned by users.

`LazyCell` [plagyround example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=9cf38b8dc56db100848f54085c2c697d)

`LazyLock` [playground example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=f1cd6f9fe16636e347ebb695a0ce30c0)

# Open Questions

- [x] Is it worth making the implementation of `LazyLock` more complicated to ensure that the the panic message is `"LazyLock instance has previously been poisoned"` instead of `"Once instance has previously been poisoned"`? See the `LazyLock` playground link above for more context.
- [x] Does it make sense to move `LazyLock` into the `poison` module? It is certainly a poison-able type, but at the same time it is slightly different from the 4 other types currently in the `poison` module in that it is unrecoverable. I think this is more of a libs-api question.

``@rustbot`` label +T-libs-api

Please let me know if these open questions deserve a separate issue / PR!
libs-api has agreed to rename these functions to
`isolate_highest_one`/`isolate_lowest_one`
This fixes a few intrinsic docs that had a link directly to itself
instead of to the correct function in the `mem` module.
Change visibility of Args new function

Currently the Args new function is constrained to pub(super) but this stops me from being able to construct Args structs in unit tests.

This pull request is to change this to pub.
…iper

Correct the use of `must_use` on btree::IterMut

I'm working on stricter target checking for attributes and found this one
…htriplett

num: Rename `isolate_most_least_significant_one` functions

Tracking issue - rust-lang#136909

libs-api has agreed to rename these unstable functions to `isolate_highest_one`/`isolate_lowest_one`
rust-lang#136909 (comment)

`isolate_most_significant_one` -> `isolate_highest_one`
`isolate_least_significant_one` -> `isolate_lowest_one`
Fix some doc links for intrinsics

This fixes a few intrinsic docs that had a link directly to itself instead of to the correct function in the `mem` module.
@github-actions github-actions bot requested a review from a team as a code owner August 8, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.