Skip to content
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

Update subtree/library to 2025-03-17 #289

Merged
merged 93 commits into from
Mar 19, 2025

Conversation

github-actions[bot]
Copy link

This is an automated PR to update the subtree/library branch to the changes
from 2025-03-13 (249cb84)
to 2025-03-17 (227690a), inclusive.
Do not merge this PR using the merge queue. Instead, use the rebase strategy.

hkBst and others added 30 commits January 27, 2025 12:51
This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
Because `.as_ptr()` changes the type of the pointer (e.g. `&[u8]`
becomes `*const u8` instead of `*const [u8]`), and it can't be expected
that different types will be formatted the same way.
Make Rust pointers less magic by including metadata information in their
`Debug` output.

This does not break Rust stability guarantees because `Debug` output is
explicitly exempted from stability:
https://doc.rust-lang.org/std/fmt/trait.Debug.html#stability

Co-authored-by: Lukas <[email protected]>
Co-authored-by: Josh Stone <[email protected]>
- UEFI device path is a series of nodes layed out in a contiguous memory
  region. So it makes sense to use Iterator abstraction for modeling
  DevicePaths
- This PR has been split off from rust-lang#135368 for easier review. The allow
  dead_code will be removed in rust-lang#135368

Signed-off-by: Ayush Singh <[email protected]>
These gates are unnecessary now that unit tests for `core` are in a
separate package, `coretests`, instead of in the same files as the
source code. They previously prevented the two `core` versions from
conflicting with each other.
* Clarify relationship to `dyn` after rust-lang#133003.
* Add an example of using it with `dyn` as rust-lang#133003 enabled.
* Add an example of implementing it.
* Add links to Rust Reference for the mentioned concepts.
* Mention that its method should rarely be called.
* Replace parameter name `dst` with `dest` to avoids confusion between
  “DeSTination” and “Dynamically-Sized Type”.
* Various small corrections.
Co-authored-by: Thalia Archibald <[email protected]>
Unclear why this needs to be done manually and is not done by the existing Trusty patches.
It also now demonstrates how to avoid memory leaks.
* Give example of how to get the offset of an unsized tail field
  (prompted by discussion <rust-lang#133055 (comment)>).
* Specify the return type.
* Add section headings.
* Reduce “Visibility is respected…”, to a single sentence.
matthiaskrgr and others added 27 commits March 13, 2025 17:44
…hpratt

Remove `feature = "hash_raw_entry"`

The `hash_raw_entry` feature finished [fcp-close](rust-lang#56167 (comment)) back in August, and its remaining uses in the compiler have now been removed, so we should be all clear to remove it from `std`.

Closes rust-lang#56167
Redox OS is moving away from name:/path style paths to /scheme/name/path
style paths which are already handled correctly without has_redox_scheme.
…oli-obk

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
Overhaul examples for PermissionsExt

This fixes rust-lang#91707 by including one overarching example, instead of the small examples that can be misleading.
…mptions, r=cuviper

Reword incorrect documentation about SocketAddr having varying layout

This has no longer been the case since these types were moved to `core`. The note on portability remains, but it is reworded to not imply that the size varies by target.
…s-137566, r=cuviper

 Improve HashMap docs for const and static initializers

Closes rust-lang#137566.
I clarified the HashMap usage in const and static initializers.
I also added examples of how to construct such HashMaps wrapped in LazyLock.
…nce, r=nnethercote

atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance

The provenance semantics match what Miri implements and what the `AtomicPtr` API expects.
…rieb

Remove usage of legacy scheme paths on RedoxOS

The `name:/path` path syntax is getting phased out[^1] in favor of `/scheme/name/path`. Also using `null:` is no longer necessary as `/dev/null` is available on Redox OS too.

[^1]: https://gitlab.redox-os.org/redox-os/rfcs/-/blob/master/text/0006-scheme-path.md

cc `@jackpot51`
Rollup of 16 pull requests

Successful merges:

 - rust-lang#136001 (Overhaul examples for PermissionsExt)
 - rust-lang#136230 (Reword incorrect documentation about SocketAddr having varying layout)
 - rust-lang#136892 (Sync Fuchsia target spec with clang Fuchsia driver)
 - rust-lang#136911 (Add documentation URL to selected jobs)
 - rust-lang#137870 ( Improve HashMap docs for const and static initializers)
 - rust-lang#138179 (Add `src/tools/x` to the main workspace)
 - rust-lang#138389 (use `expect` instead of `allow`)
 - rust-lang#138396 (Enable metrics and verbose tests in PR CI)
 - rust-lang#138398 (atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance)
 - rust-lang#138432 (fix: remove the check of lld not supporting `@response-file)`
 - rust-lang#138434 (Visit `PatField` when collecting lint levels)
 - rust-lang#138441 (update error message)
 - rust-lang#138442 (EUV: fix place of deref pattern's interior's scrutinee)
 - rust-lang#138457 (Remove usage of legacy scheme paths on RedoxOS)
 - rust-lang#138461 (Remove an outdated line from a test comment)
 - rust-lang#138466 (Remove myself from libs review)

Failed merges:

 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)

r? `@ghost`
`@rustbot` modify labels: rollup
…bishop,cuviper

uefi: helpers: Add DevicePathNode abstractions

- UEFI device path is a series of nodes layed out in a contiguous memory region. So it makes sense to use Iterator abstraction for modeling DevicePaths
- This PR has been split off from rust-lang#135368 for easier review. The allow dead_code will be removed in rust-lang#135368

cc `@nicholasbishop`
…e, r=ibraheemdev

remove must_use from <*const T>::expose_provenance

`<*mut T>::expose_provenance` does not have this attribute, and in fact the function is documented to have a side-effect, so there are perfectly legitimate use-cases where the return value would be ignored.
…anteed-no-drop, r=lcnr

Deny impls for `BikeshedGuaranteedNoDrop`

r? lcnr
Rollup of 9 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137619 (Provide helpful diagnostics for shebang lookalikes)
 - rust-lang#138353 (remove must_use from <*const T>::expose_provenance)
 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - rust-lang#138469 (remove comment regarding a removed test directive)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - rust-lang#138485 (Rustc dev guide subtree update)
 - rust-lang#138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - rust-lang#138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
…mulacrum

Expand `CloneToUninit` documentation.

* Clarify relationship to `dyn` after rust-lang#133003.
* Add an example of using it with `dyn` as rust-lang#133003 enabled.
* Replace parameter name `dst` with `dest` to avoid confusion between abbreviations for “DeSTination” and “Dynamically-Sized Type”.
* Add an example of implementing it.
* Add links to Rust Reference for the mentioned concepts.
* Mention that its method should rarely be called.
* Various small corrections.

Please review the `unsafe` code closely, as I am not an expert in the best possible ways to express these operations. (It might also be better to omit the implementation example entirely.)

cc `@zachs18` rust-lang#126799
…onsume, r=Mark-Simulacrum

doc: clarify that consume can be called after BufReader::peek

tracking issue rust-lang#128405
…thomcc

Remove `#[cfg(not(test))]` gates in `core`

These gates are unnecessary now that unit tests for `core` are in a separate package, `coretests`, instead of in the same files as the source code. They previously prevented the two `core` versions from conflicting with each other.
…-detected, r=Mark-Simulacrum

expose `is_s390x_feature_detected!` from `std::arch`

tracking issue: rust-lang#135413
implementation: rust-lang/stdarch#1699 (more features added in rust-lang/stdarch#1720)

This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`.

r? libs
Fix Ptr inconsistency in {Rc,Arc}

### PR Description
This pr aims to address the problem discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Inconsistency.20in.20.7BRc.2CArc.7D's.20ptr.20requirements/with/504259637).

### Problem Clarification
As this post presents, the `{Rc, Arc}::{in/de-crement_strong_count_/in}` do not limit the layout of the memory that `ptr` points to, while internally `Rc::from_raw_in` is called directly.

UB doesn't just appear when the strong count is decremented to zero. Miri also detects the UB of `out-of-bounds pointer use` when increment strong count is called on a pointer with an incorrect layout(shown as below).

```rust
use std::rc::Rc;
#[repr(align(8))]
struct Aligned8(u64);

#[repr(align(16))]
struct Aligned16(u64);

fn main() {
    let rc: Rc<Aligned8> = Rc::new(Aligned8(42));
    let raw_ptr = Rc::into_raw(rc);

    unsafe {
        Rc::increment_strong_count(raw_ptr as *const Aligned16);
    }
}
```

Miri output:
```
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 32 bytes of memory, but got alloc954 which is only 24 bytes from the end of the allocation
```
Add missing doc for intrinsic (Fix PR135334)

The previous [PR135334](rust-lang#135334) mentioned that some of the intrinsic APIs were missing safety descriptions.

Among intrinsic APIs that miss safety specifications, most are related to numerical operations. They might need to be discussed and then seen how to organize.

Apart from them, only a few intrinsics lack safety. So this PR deals with the APIs with non-numerical operations in priority.
…acrum

Expand and organize `offset_of!` documentation.

* Give example of how to get the offset of an unsized tail field (prompted by discussion <rust-lang#133055 (comment)>).
* Specify the return type.
* Add section headings.
* Reduce “Visibility is respected…”, to a single sentence.
* Move `offset_of_enum` documentation to unstable book (with link to it).
* Add `offset_of_slice` documentation in unstable book.

r? Mark-Simulacrum
…acrum

debug-assert that the size_hint is well-formed in `collect`

Closes rust-lang#137919

In the hopes of helping to catch any future accidentally-incorrect rustc or stdlib iterators (like the ones rust-lang#137908 accidentally found), this has `Iterator::collect` call `size_hint` and check its `low` doesn't exceed its `Some(high)`.

There's of course a bazillion more places this *could* be checked, but the hope is that this one is a good tradeoff of being likely to catch lots of things while having minimal maintenance cost (especially compared to putting it in *every* container's `from_iter`).
core: Make `Debug` impl of raw pointers print metadata if present

Make Rust pointers appear less magic by including metadata information in their `Debug` output.

This does not break Rust stability guarantees because `Debug` impl are explicitly exempted from stability:
https://doc.rust-lang.org/std/fmt/trait.Debug.html#stability

> ## Stability
>
> Derived `Debug` formats are not stable, and so may change with future Rust versions. Additionally, `Debug` implementations of types provided by the standard library (`std`, `core`, `alloc`, etc.) are not stable, and may also change with future Rust versions.

Note that a regression test is added as a separate commit to make it clear what impact the last commit has on the output.

Closes rust-lang#128684 because the output of that code now becomes:

```
thread 'main' panicked at src/main.rs:5:5:
assertion `left == right` failed
  left: Pointer { addr: 0x7ffd45c6fc6b, metadata: 5 }
 right: Pointer { addr: 0x7ffd45c6fc6b, metadata: 3 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
libstd: rustdoc: correct note on fds 0/1/2 pre-main

Closes: rust-lang#137490
… r=jhpratt

Optimize multi-char string patterns

Uses specialization for `[T]::contains` from rust-lang#130991 to optimize multi-char patterns in string searches.
Requesting a perf run to see if this actually has an effect 🙏
(I think that adding `char` to the list of types for which the `SliceContains` is specialized is a good idea, even if it doesn't show up on perf - might be helpful for downstream users)
@tautschnig tautschnig merged commit f96d31e into subtree/library Mar 19, 2025
@tautschnig tautschnig deleted the update-subtree/library branch March 19, 2025 20:21
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.