Skip to content

Update subtree/library to 2025-05-26 #366

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 61 commits into
base: subtree/library
Choose a base branch
from

Conversation

github-actions[bot]
Copy link

This is an automated PR to update the subtree/library branch to the changes from 2025-05-20 (rust-lang/rust@60dabef) to 2025-05-26 (rust-lang/rust@283db70), inclusive.
Review this PR as usual, but do not merge this PR using the GitHub web interface. Instead, once it is approved, use git push to literally push the changes to subtree/library without any rebase or merge.

joshlf and others added 30 commits February 20, 2025 08:23
This updates some doctests that fail to run on android. We will soon be
supporting cross-compiled doctests, and the `arm-android` job fails to
run these tests.

In summary:
- Android re-exports some traits from linux under a different path.
- Android doesn't seem to have common unix utilities like `true`,
  `false`, or `whoami`, so these are disabled.
This updates some doctests that fail to run on wasm. We will soon be
supporting cross-compiled doctests, and the test-various job fails to
run these tests. These tests fail because wasm32-wasip1 does not support
threads.
When `try_fold` is overriden, it is usually easier for compilers to
optimize.
…tence

As inspired by the equivalent methods from other collection types.

Signed-off-by: Paul Mabileau <[email protected]>
…alue`

A minor change, but it seemed interesting to unify this one's
description, especially considering all the other equivalents use
`element` as well.

Signed-off-by: Paul Mabileau <[email protected]>
…owing ones

This also seems like a small mistake: the first main sentence is put in
the same paragraph as the other two following ones while other
equivalents all have it split. Therefore, do the same here.

Signed-off-by: Paul Mabileau <[email protected]>
Also fixes `HashSet`'s that incorrectly designated itself as a `list`.

Signed-off-by: Paul Mabileau <[email protected]>
Take the one from `BTreeMap` that seems the best-worded and most
precise among the available variations.

Signed-off-by: Paul Mabileau <[email protected]>
Make it consistent in this regard with `BTreeMap`'s.

Signed-off-by: Paul Mabileau <[email protected]>
At [1] it was pointed out that `cfg_match!` syntax does not actually
align well with match syntax, which is a possible source of confusion.
The comment points out that usage is instead more similar to ecosystem
`select!` macros. Rename `cfg_match!` to `cfg_select!` to match this.

Tracking issue: rust-lang#115585

[1]: rust-lang#115585 (comment)
8 and 16-bit integers are subject to upcasting in C, and hence are not reliably safe. users should perform their own casting and deal with the consequences
…n, r=dtolnay

docs: Specify that common sort functions sort in an ascending direction

From [forum discussion](https://users.rust-lang.org/t/is-there-a-way-to-sort-a-slice-in-specifically-ascending-or-descending-order/128998?u=natr1x) it seems like the sorting direction can be expected to always be ascending (in terms of `cmp::Ordering`).

If this is the case then it would be nice to have this stated in the documentation.
std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque`

Fixes rust-lang#141217

r? libs
…r=workingjubilee

limit impls of `VaArgSafe` to just types that are actually safe

tracking issue: rust-lang#44930

Retrieving 8- or 16-bit integer arguments from a `VaList` is not safe, because such types are subject to upcasting. See rust-lang#61275 (comment) for more detail.

This PR also makes the instances of `VaArgSafe` visible in the documentation, and uses a private sealed trait to make sure users cannot create additional impls of `VaArgSafe`, which would almost certainly cause UB.

r? `@workingjubilee`
Rename `cfg_match!` to `cfg_select!`

[`@Nemo157` pointed out](rust-lang#115585 (comment)) that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this.

Tracking issue: rust-lang#115585

[1]: rust-lang#115585 (comment)
bump stdarch

This should unblock rust-lang#135160.
r? `@Amanieu`
add doc alias `replace_first` for `str::replacen`

`replace_first` is a sensible name for a function, analogous to actually existing `<[_]>::split_first`, for example. (I just saw someone try to search for it)

I think it's reasonable to add such an alias for `replacen`, which replaces the first occurrence of passed a 1.
RalfJung and others added 30 commits May 22, 2025 13:32
rustc_on_unimplemented cleanups

Addresses some of the fixmes from rust-lang#139091 and rust-lang#140307.

- switch from `_Self` to `Self` in library
- properly validate that arguments in the `on` filter and the format strings are actually valid

See rust-lang/rustc-dev-guide#2357 for the relevant documentation.
…rovenance, r=tgross35

try_cast_aligned: avoid bare int-to-ptr casts

This fixes a CI failure in https://github.com/rust-lang/miri-test-libstd caused by strict provenance violations in doctests added in rust-lang#141222.

r? `@tgross35`
Cc `@mathisbot`
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#135562 (Add ignore value suggestion in closure body)
 - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts)
 - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds)
 - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths)
 - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts)
 - rust-lang#141130 (rustc_on_unimplemented cleanups)
 - rust-lang#141286 (Querify `coroutine_hidden_types`)

Failed merges:

 - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs)

r? `@ghost`
`@rustbot` modify labels: rollup
…Mark-Simulacrum

Update std doctests for android

This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests.

In summary:
- Android re-exports some traits from linux under a different path.
- Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
…mulacrum

discuss deadlocks in the std::io::pipe() example

I think it's important to discuss deadlocks in examples of how to use pipes. The current example does include an explicit `drop()`, but it also implicitly relies on the fact that the `Command` object is temporary, so that it drops its copy of `pong_tx`. This sort of thing tends to trip people up when they use pipes for the first time. I might've gone overboard with the comments in this version, but I'm curious what folks think.
`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
- Implement TCP4 connect using EFI_TCP4_PROTOCOL.
- Tested on QEMU setup with connecting to TCP server on host.

Signed-off-by: Ayush Singh <[email protected]>
std: fix aliasing bug in UNIX process implementation

`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
…k-Simulacrum

Updated std doctests for wasm

This updates some doctests that fail to run on wasm. We will soon be supporting cross-compiled doctests, and the test-various job fails to run these tests. These tests fail because wasm32-wasip1 does not support threads.
chore: fix typos in comment

## Fix Typos in Comments

This PR addresses several typos in the Rust standard library's documentation comments:

- In `library/std/src/sync/mpmc/list.rs`: Corrected "attemped" to "attempted"
- In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "defering" to "deferring"
- In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "futher" to "further"

These changes improve documentation readability and consistency without affecting any functional code.
Remove #![feature(let_chains)] from libcore

PR rust-lang#132833 has stabilized the let_chains feature. This PR removes the last occurrence from the library.

Split out of rust-lang#140966 as it caused breakage. Now we have a patch to the linux tree that fixes the build, so we update the linux tree to it.

cc Rust-for-Linux/linux#1163
cc rust-lang#140722
… r=ChrisDenton

GetUserProfileDirectoryW is now documented to always store the size

Update to match MicrosoftDocs/sdk-api#1810

Also fix a bug in the Miri implementation while I am starting at that code...

r? ```@ChrisDenton```
Fixes rust-lang#141254
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#141405 (GetUserProfileDirectoryW is now documented to always store the size)
 - rust-lang#141427 (Disable `triagebot`'s `glacier` handler)
 - rust-lang#141429 (Dont walk into unsafe binders when emiting error for non-structural type match)
 - rust-lang#141438 (Do not try to confirm non-dyn compatible method)
 - rust-lang#141444 (Improve CONTRIBUTING.md grammar and clarity)
 - rust-lang#141446 (Add 2nd Solaris target maintainer)
 - rust-lang#141456 (Suggest correct `version("..")` predicate syntax in check-cfg)

r? `@ghost`
`@rustbot` modify labels: rollup
Reduce boilerplate in doctests by replacing fallible function calls with
literals.
Guarantee behavior of transmuting `Option::<T>::None` subject to NPO

In rust-lang#115333, we added a guarantee that transmuting from `[0u8; N]` to `Option<P>` is sound where `P` is a pointer type subject to the null pointer optimization (NPO). It would be useful to be able to guarantee the inverse - that a `None::<P>` value can be transmutes to an array and that will yield `[0u8; N]`.

Closes rust-lang#117591
std: sys: net: uefi: Implement TCP4 connect

- Implement TCP4 connect using EFI_TCP4_PROTOCOL.
- Tested on QEMU setup with connecting to TCP server on host.
…ce, r=jhpratt

Stabilize `<[T; N]>::as_mut_slice` as `const`

This is trivial and has no design questions.

Tracked in rust-lang#133333.

r? libs-api
…r=jhpratt

additional edge cases tests for `path.rs` 🧪

This pull request adds a few new edge case tests to the `std::path` module. The new tests cover scenarios such as paths with only separators, non-ASCII and Unicode characters, embedded new lines, etc. Each new test is documented with some helpful in-line comments as well.
Use C-string literals to reduce boilerplate

Reduce boilerplate in doctests by replacing fallible function calls with
literals.
rename internal panicking::try to catch_unwind

The public function is called `catch_unwind`, the intrinsic at some point got renamed to `catch_unwind` -- there's no reason to have the internal implementation of this still be called `try`, so let's rename it to match the rest.
…ark-Simulacrum

Docs(lib): Fix `extract_if` docs

Various fixes to the documentation comments of the several `extract_if` collection methods available. It originally started with a small typo fix in `Vec`'s spotted when reading the 1.87 release notes, but then by looking at the others' for comparison in order to try determining what was the intended sentence, some inconsistencies were spotted. Therefore, some other changes are also proposed here to reduce these avoidable differences, going more and more nit-picky along the way. See the individual commits for more details about each change.

`@rustbot` label T-libs A-collections A-docs
…ubilee

use `cfg_select!` to select the right `VaListImpl` definition

tracking issue: rust-lang#44930

Just a bit of cleanup really.

We could use `PhantomInvariantLifetime<'f>` (rust-lang#135806) to make it more precise what that `PhantomData<&'f mut &'f c_void>` marker is doing. I'm not sure how ready that feature is though, `@jhpratt` are these types good to use internally?

---

Some research into the lifetimes of `VaList` and `VaListImpl`:

It's easy to see why the lifetime of these types should not be extended, a `VaList` or `VaListImpl` escaping its function is a bad idea. I don't currently see why coercing the lifetime to a shorter lifetime is problematic though, but probably I just don't understand variance well enough to see it. The history does not provide much explanation:

- immunant@0814087 original implementation
- immunant@b9ea653 adds `VaListImpl<'f>`, but it is only covariant in `'f`
- rust-lang#62639 makes `VaListImpl<'f>` invariant over `'f` (because `VaList<'a, 'f>` is already invariant over `'f`, but I think that is just an implementation detail?)

Beyond that I don't see how the lifetime situation can be simplified significantly, e.g. this function really needs `'copy` to be unconstrained.

```rust
/// Copies the `va_list` at the current location.
pub unsafe fn with_copy<F, R>(&self, f: F) -> R
where
    F: for<'copy> FnOnce(VaList<'copy, 'f>) -> R,
{
    let mut ap = self.clone();
    let ret = f(ap.as_va_list());
    // SAFETY: the caller must uphold the safety contract for `va_end`.
    unsafe {
        va_end(&mut ap);
    }
    ret
}
```

`@rustbot` label +F-c_variadic
r? `@workingjubilee`
Implement `advance_by` via `try_fold` for `Sized` iterators

When `try_fold` is overriden, it is usually easier for compilers to optimize.

Example difference: https://iter.godbolt.org/z/z8cEfnKro
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.