Commit Graph

9065 Commits

Author SHA1 Message Date
Sidney Cammeresi 70fe8a6dc4 Add Sender diagnostic item for std::sync::mpsc::Sender
Similar to the existing `Receiver` item, it will be used in Clippy to
detect uses of `is_disconnected` that are racy.
2026-04-23 17:19:39 -07:00
Alex Crichton 1dea6b8c3b std: Update support for wasm32-wasip3
This commit performs some minor update within the standard library for
the `wasm32-wasip3` target. This target is a tier 3 target currently due
to the WASIp3 specification not being officially released. This commit
adds a dependency from the standard library on the `wasip3` crate in the
same manner as the `wasip1` and `wasip2` crates that it already depends
on. The use-sites, for randomness and environment variables, are then
updated to handle the wasip2/wasip3 multiplexing.
2026-04-21 09:26:25 -07:00
Jacob Pratt 387df6efb1 Rollup merge of #155532 - StepfenShawn:patch-1, r=jhpratt
Fix redundant boolean comparison in `Mutex::try_lock`

Simplify boolean return in `Mutex::try_lock`.
Replace `expr == false` with `!expr` for cleaner code.
2026-04-21 02:20:25 -04:00
Zac Harrold fe2b39f064 Move std::io::ErrorKind to core::io
Move `std::io::ErrorKind` to `core::io`
* Update `rustdoc-html` tests for the new path
* Add `core_io` feature to control stability. This replaces the use of `core_io_borrowed_buf` on the `core::io` module itself.
* Re-export `core::io::ErrorKind` in `std::io::error`
2026-04-20 18:38:25 +10:00
🍌Shawn e1059f6e53 Fix redundant boolean comparison in Mutex::try_lock 2026-04-20 09:49:52 +08:00
Zac Harrold 6960e7c958 Adjust usage of std::io::ErrorKind to be core compatible
* Checking exhaustion will no longer be possible for `repr_bitpacked`. Moving `kind_from_prim` into an associated function, and setting it up to be moved into `core::io` as well.
* `ErrorKind::as_str` is private, but it's only usage is trivially replaced with `Display::fmt`
* The features io_error_inprogress, io_error_more, and io_error_uncategorized will all need to be enabled
2026-04-20 08:29:15 +10:00
Zac Harrold 08bd077df4 Make documentation for std::io::ErrorKind core::io compatible
Certain links will not be valid when moved into `core::io`
2026-04-20 08:29:15 +10:00
Jonathan Brouwer e7c135e282 Rollup merge of #154979 - ArtemIsmagilov:must-use-floats, r=jhpratt
add #[must_use] macros for floats

try resolve rust-lang/rust#154854
2026-04-19 16:04:33 +02:00
Jonathan Brouwer 22aef0f0ae Rollup merge of #155406 - alexcrichton:update-wasi-deps, r=Mark-Simulacrum
std: Update dependency on `wasi` crate

This commit updates the crate dependency that the standard library has on the `wasi` crate. This is now updated to depending explicitly on the `wasip1` crate and the `wasip2` crate published on crates.io. These crates are managed in the [same location][repo] as the `wasi` crate and represent a different versioning scheme which doesn't require multi-version WASI support to require depending on the same crate at multiple versions. The code in libstd is updated to reference `wasip1` and `wasip2` directly as well.

[repo]: https://github.com/bytecodealliance/wasi-rs
2026-04-18 19:23:16 +02:00
Jonathan Brouwer f0df37fac1 Rollup merge of #155255 - Zoxc:ub-issue-16, r=Mark-Simulacrum
Document why `layout.align() + layout.size()` doesn't overflow

This addition looks suspicious and is safety critical, but is saved by the weird `Layout` invariants.
2026-04-18 19:23:15 +02:00
Jonathan Brouwer 74fd4a720f Rollup merge of #155187 - ArshLabs:fix/hashmap-rng-doc-wording, r=Mark-Simulacrum
std: fix HashMap RNG docs wording

Fixes a wording typo in the top-level HashMap docs.

Changed "random number coroutine" to "random number generator" in the seed entropy paragraph.

This section is security-relevant, and "generator" is the correct term in RNG context.

Testing:
- Not run locally (docs-only text change).
2026-04-18 19:23:14 +02:00
Jonathan Brouwer f7668674cc Rollup merge of #154003 - ginnyTheCat:uefi-file-send, r=Mark-Simulacrum
Make std::fs::File Send on UEFI

Similarly to rust-lang/rust#150990 since UEFI has no threads, this should be safe.
2026-04-18 19:23:14 +02:00
Jonathan Brouwer e28fb66f82 Rollup merge of #155284 - RalfJung:net-nonblocking, r=Mark-Simulacrum
net::tcp/udp: fix docs about how set_nonblocking is implemented

`fcntl` `FIONBIO` doesn't even make sense, it should be `fcntl` `F_SETFL`. However, for some reason we are using `ioctl` by default -- except on Solaris where this doesn't seem to work very well.

Honestly what I would have expected is that we just always use `FileDesc::set_nonblocking` also for network sockets, but for some reason we don't and there are no comments explaining this choice. Cc @nikarh (for "vita") @joboet
2026-04-18 19:23:12 +02:00
Artem Ismagilov 607021cb1d add must_use macros
add msg
2026-04-18 11:23:14 +04:00
Jacob Pratt 4fa293c965 Rollup merge of #155454 - MadeInShineA:issue-155275-fix, r=lqd
docs: Fix typo in std/src/thready/scoped.rs

# Fix typo in std/src/thread/scoped.rs

## Why this pr

This PR fixes the typo mentioned in rust-lang/rust#155275.

I know this was originally fixed in rust-lang/rust#155325 and then in rust-lang/rust#155328.

But since the first issue was closed due to some ai slop and the second one was closed because the first one was already opened, it seems to me that this PR is still needed.

## What this pr does

This PR "just" fixes a typo inside the `std/src/thread/scoped.rs` file

Changing the comment from this:

```
/// borrow non-`'static` data from the outside the scope. See [`scope`] for
/// details.
```

to this:

```
/// borrow non-`'static` data from outside the scope. See [`scope`] for
/// details.
```
2026-04-18 00:05:21 -04:00
Olivier Amacker 10cc6c4a39 docs: Fix typo in std/src/thread/scoped.rs 2026-04-17 19:39:18 +02:00
Jonathan Brouwer ea736ba569 Rollup merge of #149614 - WaffleLapkin:dangle-maybe, r=jhpratt
Use `MaybeDangling` in `std`

cc https://github.com/rust-lang/rust/issues/118166
2026-04-17 13:28:57 +02:00
Stuart Cook 9de2e2bfd7 Rollup merge of #155413 - StepfenShawn:patch-2, r=ChrisDenton
fix: typo in `std::fs::hard_link` documentation

Change "corresponds the" to "corresponds to the" in the documentation for `std::fs::hard_link`.
2026-04-17 16:18:02 +10:00
Stuart Cook 6951f83914 Rollup merge of #155335 - Mark-Simulacrum:bootstrap-bump, r=jieyouxu
Bump bootstrap to 1.96 beta

See https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday

I think this will wind up needing another PR in a week or so when we pick up assert_matches getting destabilized in beta? But that seems like it can be split into its own PR.
2026-04-17 16:17:52 +10:00
Stuart Cook b7ea9df119 Rollup merge of #155318 - Zoxc:ub-issue-50, r=ChrisDenton
Use mutable pointers for Unix path buffers

This gets mutable pointers for Unix path buffers to ensure they have the right provenance.
2026-04-17 16:17:51 +10:00
🍌Shawn b05e29b8cb Fix typo in documentation for CreateHardLink function 2026-04-17 11:52:59 +08:00
John Kåre Alsaker 7a47964d3f Use mutable pointers for Unix path buffers 2026-04-17 01:08:08 +02:00
Alex Crichton 690be3e13c std: Update dependency on wasi crate
This commit updates the crate dependency that the standard library has
on the `wasi` crate. This is now updated to depending explicitly on the
`wasip1` crate and the `wasip2` crate published on crates.io. These
crates are managed in the [same location][repo] as the `wasi` crate and
represent a different versioning scheme which doesn't require
multi-version WASI support to require depending on the same crate at
multiple versions. The code in libstd is updated to reference `wasip1`
and `wasip2` directly as well.

[repo]: https://github.com/bytecodealliance/wasi-rs
2026-04-16 14:11:28 -07:00
Jacob Pratt 2beaa602c4 Rollup merge of #154604 - CAD97:abort-immediate, r=scottmcm
abort in core

Implements `core::process::abort_immediate` as a wrapper around `intrinsics::abort`.

- tracking issue: https://github.com/rust-lang/rust/issues/154601

(This PR used to also add `core::process::abort`, but that's been deferred to a later addition.)
2026-04-16 01:54:09 -04:00
Folkert de Vries 2fe569d25f bump std libc to 0.2.185 2026-04-15 11:56:20 +02:00
Jacob Pratt 3f19aa5672 Rollup merge of #153469 - Albab-Hasan:doc/command-path-search-behavior, r=ChrisDenton
docs: clarify path search behavior in std::process::Command::new

the existing docs mentioned that `PATH` is searched in an "os defined way" and that it could be controlled by setting PATH on the command but never explained which `PATH` is actually used.

on unix the key thing to understand is that when you modify the childs environment (via `env()`, `env_remove()`, or `env_clear()`), the `PATH` search uses whatever `PATH` ends up in the child's environment not the parents. so if you call `env_clear()` and forget to set `PATH`, you don't get the parents `PATH` as a fallback; you get the OS default (typically `/bin:/usr/bin`) which often won't find what you need.

the three cases are now documented:
- unmodified env: child inherits parents `PATH`, that gets searched
- `PATH` explicitly set `via env()`: the new value is searched
- `PATH` removed (`env_clear` or `env_remove`): falls back to OS default, not the parents `PATH`

on windows rust resolves the executable before spawning rather than letting `CreateProcessW` do it. the search order is: childs `PATH` (if explicitly set) first then system-defined directories then the parents `PATH`. the existing note about issue rust-lang/rust#37519 is preserved.

limitations in this doc:
- the unix fallback path behavior ("typically `/bin:/usr/bin`") is verified for linux/glibc. behavior on macOS, BSD, and musl is similar in practice but not fully confirmed here.
- the windows search order is summarized as "system-defined directories" which actually includes the application directory (the directory of the calling process's executable) as a distinct step before the system dirs that detail is omitted for brevity.
- `posix_spawnp` `PATH` source (calling process environ vs envp argument) is ambiguous in the `POSIX` spec; the behavior here is inferred from the guard in `unix.rs` that bypasses `posix_spawn` when `PATH` has been modified.

closes rust-lang/rust#137286 (hopefully)
2026-04-14 23:02:32 -04:00
Mark Rousskov f0827c67ca Apply replace-version-placeholder 2026-04-14 18:09:15 -04:00
Brian Smith 10cff1530d BorrowedBuf: Update outdated safety comments in set_init users.
These comments appear to have been written before `BorrowedBuf`'s
init tracking was simplified in
https://github.com/rust-lang/rust/pull/150129. The `BufWriter` comment
of the usage within `BufWriter` will be handled separately.
2026-04-14 14:59:21 -07:00
Albab Hasan a34d15f423 Update library/std/src/process.rs
Co-authored-by: Chris Denton <chris@chrisdenton.dev>
2026-04-14 23:39:04 +06:00
albab-hasan 97761a0c23 docs: move PATH search details under Platform-specific behavior, add stability
caveat
2026-04-14 23:02:47 +06:00
Ralf Jung 4e4d268b63 net::tcp/udp: fix docs about how set_nonblocking is implemented 2026-04-14 13:56:42 +02:00
Jacob Pratt 47d991a1aa Rollup merge of #152530 - orzechow:struct_like_enum_variants_docs, r=ChrisDenton
Use the term struct-like variant instead of anonymous structs for data of struct-like enum variants

The current term in the docs `anonymous structs` seems to be outdated.
I'd suggest `struct-like data` or rephrasing the whole sentence to use `struct-like variant`.

The terminology used in the [Rust Book on enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2) is
> named fields, like a struct

The [Reference on enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor) uses
> struct-like enum variant

The term `anonymous struct` on the other hand is neither mentioned in the Rust book on [structs](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html) or [enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2), nor the references on [structs](https://doc.rust-lang.org/stable/reference/items/structs.html) or [enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor).
2026-04-14 00:37:23 -04:00
bors 338dff3e3a Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
Start using pattern types in libcore



cc rust-lang/rust#135996

Replaces the innards of `NonNull` with `*const T is !null`.

This does affect LLVM's optimizations, as now reading the field preserves the metadata that the field is not null, and transmuting to another type (e.g. just a raw pointer), will also preserve that information for optimizations. This can cause LLVM opts to do more work, but it's not guaranteed to produce better machine code.

Once we also remove all uses of rustc_layout_scalar_range_start from rustc itself, we can remove the support for that attribute entirely and handle all such needs via pattern types
2026-04-13 21:54:46 +00:00
John Kåre Alsaker b9ec55bbcd Document why layout.align() + layout.size() doesn't overflow 2026-04-13 22:00:28 +02:00
bors 17584a1819 Auto merge of #155253 - JonathanBrouwer:rollup-lERdTAB, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
2026-04-13 18:32:47 +00:00
Jonathan Brouwer 8d8dcf142a Rollup merge of #154929 - davidgauch:const-default-lazy, r=jhpratt
Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank https://github.com/rust-lang/rust/pull/134628 and https://github.com/rust-lang/rust/pull/151190.
Tracking issue https://github.com/rust-lang/rust/issues/143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
2026-04-13 20:20:02 +02:00
Jonathan Brouwer 148ef32d65 Rollup merge of #153604 - rust-wasi-web:wasi-available-parallelism-fix, r=alexcrichton
Fix thread::available_parallelism on WASI targets with threads

The refactoring in ba462864f1 ("std: Use more unix.rs code on WASI targets") moved WASI from its own thread module into the shared unix.rs module. However, it did not carry over the available_parallelism() implementation for WASI with threads, causing it to fall through to the unsupported catch-all. This silently regressed the support originally added in f0b7008648.

Fix this by adding WASI to the standard UNIX cfg_select branch.

Depends on rust-lang/rust#155057 (Update libc to v0.2.184).
2026-04-13 20:19:55 +02:00
Oli Scherer 834137afd7 Use !null pattern type in libcore 2026-04-13 17:23:03 +02:00
Jonathan Brouwer d4037f7d8f Rollup merge of #153335 - Ozzy1423:removed-features, r=jdonszelmann
Add #![unstable_removed(..)] attribute to track removed features

Adds the #![unstable_removed(..)] attribute to enable tracking removed library features.
Produce an error when a removed attribute is used.
Add a test that it works.

For https://github.com/rust-lang/rust/issues/141617

r? @jyn514
2026-04-13 14:02:30 +02:00
Piotr Spieker 03306632ff Use the term struct-like variant instead of anonymous structs for struct-like enum variants
This closer follows the terminology used in the Rust Book and Reference.

[Rust Book](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2):
> named fields, like a struct

[Reference](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor):
> struct-like enum variant
2026-04-12 14:22:08 +02:00
bors 532f8f1443 Auto merge of #155154 - clarfonthey:hashbrown-0.17, r=Mark-Simulacrum
Update hashbrown to 0.17

The main benefit of this update is to include one potential UB fix and one bug; relevant changelog entries:

* Fixed potential UB in `RawTableInner::fallible_with_capacity` (rust-lang/hashbrown#692)
* Fixed incorrect length if a hasher panics during rehash (rust-lang/hashbrown#710)

cc @Amanieu

Also cc @RalfJung who had also noticed the UB issue with `-Zmiri-recursive-validation`.
2026-04-12 10:44:20 +00:00
Oscar Bray 25a92d208d Add #![unstable_removed(..)] attribute to track removed features
Move concat_idents to use the unstable_removed attribute
2026-04-12 11:18:10 +01:00
Sebastian Urban b5ddfd5be4 Fix thread::available_parallelism on WASI targets
The refactoring in ba462864f1 ("std: Use more unix.rs code on WASI
targets") moved WASI from its own thread module into the shared unix.rs
module. However, it did not carry over the available_parallelism()
implementation for WASI, causing it to fall through to the unsupported
catch-all. This silently regressed the support originally added in
f0b7008648.

Fix this by adding WASI to the sysconf-based cfg_select arm alongside
other platforms that use libc::sysconf(_SC_NPROCESSORS_ONLN). This
delegates to wasi-libc, which currently always returns 1 but opens up
the possibility for wasi-libc to report actual processor counts in the
future.

This requires libc to export _SC_NPROCESSORS_ONLN for WASI targets,
which has been added in libc 0.2.184.
2026-04-12 09:52:47 +02:00
bors 540f43a224 Auto merge of #155185 - matthiaskrgr:rollup-JYNqFhW, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#155171 (Patch musl's CVE-2026-6042 and CVE-2026-40200)
 - rust-lang/rust#153630 (Deprioritize doc(hidden) re-exports in diagnostic paths)
 - rust-lang/rust#152613 (unsafe keyword docs: bring back unsafe_op_in_unsafe_fn lint discussion)
 - rust-lang/rust#155142 (impl const Residual for ControlFlow)
2026-04-12 07:34:56 +00:00
ArshLabs dc36b8e3c2 std: fix HashMap RNG docs wording 2026-04-12 12:34:29 +05:30
Matthias Krüger ba98b3558a Rollup merge of #152613 - RalfJung:unsafe-keyword-docs, r=traviscross
unsafe keyword docs: bring back unsafe_op_in_unsafe_fn lint discussion

@traviscross in rust-lang/rust#141471 you asked me to also update the text to account for the edition change. Apparently I did that by entirely removing this part of the discussion (except for a dangling forward reference, a "see below"). Given that old editions still exist and given that `unsafe_op_in_unsafe_fn` is just a lint so the old behavior also still exists on new editions, I am no longer sure that was a good idea, so this brings back the old text with some editing to explain the current situation.
2026-04-12 08:15:47 +02:00
bors d32e620a10 Auto merge of #155166 - JonathanBrouwer:rollup-YH2oUIz, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#155057 (Update libc to v0.2.184)
 - rust-lang/rust#154967 (Test(lib/sync): Fix `test_rwlock_max_readers` for x86 Win7)
 - rust-lang/rust#154994 (don't leak internal temporaries from `dbg!`)
 - rust-lang/rust#155130 (Stabilize feature `isolate_most_least_significant_one`)
 - rust-lang/rust#154925 (Make Box/Rc/Arc::into_array allocator-aware (and add doctest))
 - rust-lang/rust#155063 (`ty::Alias`: replace `def_id: did` with `def_id`)
2026-04-12 04:25:51 +00:00
Travis Cross ae3b150378 Fix a typo 2026-04-12 04:03:30 +00:00
Jacob Pratt af4f14bd3d Rollup merge of #153871 - mattiapitossi:issue-148408, r=Mark-Simulacrum
fix spurious test failure in `metadata_access_times`

Fixes rust-lang/rust#148408

The metadata_access_times test checks if the creation of a file occurs before another file, this check happens only on Linux. While on Win and Macos we check only that the created metadata is available. Given that the SystemTime is non monotonic as Instant this test could result in failures when the system clock changes.
2026-04-11 21:12:22 -04:00
Jonathan Brouwer 59b36a5283 Rollup merge of #154994 - dianne:no-dbg-temp, r=Mark-Simulacrum
don't leak internal temporaries from `dbg!`

Fixes rust-lang/rust#154988

r? @Mark-Simulacrum as the reviewer of https://github.com/rust-lang/rust/pull/154074
2026-04-11 20:58:35 +02:00