9090 Commits

Author SHA1 Message Date
Jacob Pratt e3a6fa5082 Rollup merge of #151014 - Ayush1325:uefi-cmd-path, r=jhpratt,nicholasbishop
std: sys: process: uefi: Add program searching

- Follow UEFI Shell search flow to search for programs while launching.
- Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-04-26 21:56:42 -04:00
Jacob Pratt 12a843a020 Rollup merge of #155317 - briansmith:b/take-opt, r=Mark-Simulacrum
`std::io::Take`: Clarify & optimize `BorrowedBuf::set_init` usage.

Don't initialize `buf` if it was already initialized. Clarify safety comments.

Move the `buf.advance()` call to make the initialization more like
calling `buf.ensure_init()`, then clarify how the code here is an
optimized variant of `ensure_init`.
2026-04-26 21:56:39 -04:00
Jonathan Brouwer 9170ff7733 Rollup merge of #155574 - bushrat011899:core_io_raw_os_error, r=Mark-Simulacrum
Move `std::io::RawOsError` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: https://github.com/rust-lang/rust/pull/154654

## Description

As a part of moving components of `std::io` into `alloc::io` and `core::io`, there will need to be a new home for the type `RawOsError`. In this PR, I propose moving it to `core::io`, and removing it from `std::sys`. I suspect this will be quite controversial as it is a platform dependent type, but this is not the only instance of a type being conditioned on `target_os` in `core` (e.g., `core::os` and `core::ffi`).

Since `RawOsError` is currently unstable, I think it's reasonable to make this move now, and worry about making it platform independent if/when it is stabilized (e.g., replacing it with a wrapper around `isize` on all platforms).

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
2026-04-26 19:06:25 +02:00
Jonathan Brouwer eb779a151b Rollup merge of #155250 - ChrisDenton:pipe-fs, r=Mark-Simulacrum
Windows: Cache the pipe filesystem handle

Updates the anonymous pipe handling based on feedback from @lhecker  (see https://github.com/rust-lang/rust/pull/142517#discussion_r3065864262). This does two things:

1. Cache the handle to the pipe filesystem so we don't have to reopen it each time.
2. Use the `\Device\NamedPipe\` directly instead of the symlink to it.
2026-04-26 19:06:24 +02:00
Jonathan Brouwer 7c71f48c5d Rollup merge of #152995 - asder8215:windows_permissions_ext, r=Mark-Simulacrum
ACP Implementation of PermissionsExt for Windows

This PR implements the `PermissionsExt` for Windows ACP and adds file attribute methods in `FilePermissions` struct (to be decided whether we use them or not). See this [tracking issue](https://github.com/rust-lang/rust/issues/152956#event-22976637690) for further detail and links.

I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a `set_file_attributes()` + `from_file_attributes()` method to mirror what unix's `PermissionsExt` is doing).

Also, some relevant links on this:
* [File Attribute Constants](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants)
* [`attrib` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib)
* [SetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesa)
* [GetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileattributesa)
* [Window's File Attributes Column Values](https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values)
* [What is the 'M' attribute in Windows file system for?](https://superuser.com/questions/1621649/what-is-the-m-attribute-in-windows-file-system-for)

Note: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that.

r? @ChrisDenton
2026-04-26 19:06:23 +02:00
joboet bab4983f6c std: maintain CStringArray null-termination even if Vec::push panics 2026-04-25 15:17:36 +02:00
Jonathan Brouwer 6f536cf8f4 Rollup merge of #155741 - xtqqczze:question-mark-bufwriter-flush, r=WaffleLapkin
std: Refactor BufWriter::flush to use the `?` operator

Functionally, this is equivalent and may     be slightly more amenable to inlining.
2026-04-25 00:08:11 +02:00
Jonathan Brouwer e873839964 Rollup merge of #155621 - mejrs:document_diagnostic_on_move, r=chenyukang
Document #[diagnostic::on_move] in the unstable book.

Also adds the attribute on `std::fs::File` to stay consistent with the prose in the unstable book entry.

cc @estebank @rperier

Rendered:
<img width="791" height="903" alt="image" src="https://github.com/user-attachments/assets/a27a5211-7717-4f7f-a514-8316dccc78d5" />
<img width="779" height="390" alt="image" src="https://github.com/user-attachments/assets/a983108d-575e-4551-ab14-28611344e9b0" />
2026-04-24 18:19:14 +02:00
xtqqczze 15e60ebe6e std: Refactor flush method in BufWriter to use the ? operator 2026-04-24 15:19:36 +01:00
Jacob Pratt 46362de036 Rollup merge of #155669 - cammeresi:20260422-sender-diag, r=mejrs
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.

Tracking issue: rust-lang/rust#153668
Suggested: https://github.com/rust-lang/libs-team/issues/748#issuecomment-4032790302
2026-04-24 02:42:51 -04:00
Jacob Pratt e002c6c726 Rollup merge of #155684 - bushrat011899:blanket_io_seek_for_ref, r=jhpratt
Generalize IO Traits for `Arc<T>` where `&T: IoTrait`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: rust-lang/rust#94744

## Description

After experimenting with rust-lang/rust#155625, I noticed `Seek` and `SeekFrom` can almost be moved to `core::io`. Unfortunately, the implementation of `Seek` for `Arc<File>` is a blocker for such a move, since `Arc` is not a fundamental type. This PR attempts to resolve this potential blocker by replacing the implementation with a more general alternative. An internal trait `IoHandle` has been added which types can implement to opt-in to `Read`/`Write`/`Seek` implementations for `Arc<Self>` as long as `&Self` implements said trait. Note that `BufRead` is excluded as the signature for `fill_buf` would require returning from a temporary.

Since this "blanket" implementation only applies to a single type which already implements the same traits, I believe this should have no user-facing impact.

If this PR was merged, rust-lang/rust#134190 could be replaced with a 2 line PR:
```rust
impl IoHandle for TcpStream {}
impl IoHandle for UnixStream {}
```
Likewise for any other types, a table of which can be found [here](https://github.com/rust-lang/libs-team/issues/504#issuecomment-2539569736). This is out of scope for this PR to avoid the need for an ACP.

---

## Notes

* See [this comment](https://github.com/rust-lang/rust/issues/154046#issuecomment-4303975612) for further details.
* No AI tooling of any kind was used during the creation of this PR.
2026-04-24 02:42:49 -04:00
Zac Harrold 7ba9478184 Implement Read/Write/Seek for Arc<T>
Added a marker trait `IoHandle` which can be used by the standard library to opt-in types to a blanket implementation of the various IO traits on `Arc<T>` where `&T: IoTrait` for some `IoTrait`.

The marker is required to avoid types like `Arc<[u8]>`  being included, since they don't have interior mutability and would not give expected results.
2026-04-24 14:26:09 +10:00
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
Brian Smith 3a0a14fd7c <Take as Read>::read_buf: Don't initialize buf if it was already initialized. 2026-04-22 11:38:04 -07:00
Brian Smith c716ce5c2e <Take as Read>::read_buf: Clarify safety comments and naming. 2026-04-22 11:38:04 -07:00
Brian Smith 71076f2338 <Take as Read>::read_buf: Eliminate unneeded local variables.
Eliminate `cursor` and `ibuf` as named variables, as their presence
makes things more confusing.
2026-04-22 11:36:50 -07:00
Brian Smith 4abc28f570 <Take as Read>::read_buf: Clarify local variable name. 2026-04-22 11:34:05 -07:00
Chris Denton 110e67c9c2 Expand Path::is_empty docs 2026-04-22 17:41:52 +00:00
mejrs 70cf3f4fda Put #[diagnostic::on_move] on File 2026-04-21 23:42:33 +02: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
Chris Denton a6ec2947a3 Explicitly note that we're leaking a handle 2026-04-21 04:25:35 +00:00
Zac Harrold 7653e5ea01 Move RawOsError to core::io 2026-04-21 09:04:58 +10:00
Zac Harrold 4cb72b3ca5 Adjust Usage of RawOsError
Inconsistently referenced through `std::sys` and `std::io`. Choosing `std::io` as the canonical source to make migration to `core::io` cleaner.
2026-04-21 09:03:32 +10:00
Zac Harrold e1ef601a73 Adjust Documentation for RawOsError
The hyperlink to `std::io::Error` will not be valid when moved to `core::io`.
There is also a typo which I might as well fix while I'm here.
2026-04-21 09:03:32 +10: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
Mahdi Ali-Raihan c567332927 Implemented PermissionsExt ACP on Windows, which provides functions/utilities to observe, set, and create a Permissions struct with certain file attributes 2026-04-19 14:46:48 -04: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