Commit Graph

9127 Commits

Author SHA1 Message Date
Jonathan Brouwer 4d2f9ca08d Rollup merge of #156365 - RalfJung:stream_send_recv_stress, r=nia-e
stream_send_recv_stress tests: wait for threads to finish

These tests currently fail in Miri (when run with nextest) because all they do is spawn a lot of threads that will do stuff, but they don't wait for the threads to actually finish. Miri by default errors when there are background threads lingering when `main` is done (since that can indicate a leak, and since it makes it impossible to check for memory leaks). Miri gives background threads a bit of time to finish when `main` is done, but for these tests that's nowhere near enough since basically the entire test runs after `main` is done.

Outside Miri, this could also still mean that the test doesn't actually run to completion, it might get abort when `main` finishes.

So let's use `thread::scope` to ensure all threads are done before the test is considered done.
2026-05-10 19:05:47 +02:00
Jonathan Brouwer dd38e55468 Rollup merge of #156387 - RalfJung:fs-error-str, r=ChrisDenton
std fs tests: avoid matching on OS-provided error string

These tests are [ancient](https://github.com/rust-lang/rust/commit/6bfbad937bdf578e35777d079f8dcfab49758041). No idea why there written in this style back then, but today we'd clearly check the `ErrorKind`, not the string.

r? @ChrisDenton
2026-05-10 19:05:45 +02:00
Ralf Jung a0298aa7e5 std fs tests: avoid matching on OS-provided error string 2026-05-10 11:34:21 +02:00
Matthias Krüger 34018578e2 Rollup merge of #156133 - RalfJung:time-panic-track-caller, r=Mark-Simulacrum
mark some panicking methods around Duration as track_caller

Currently when they panic it looks like this
```
  0.005045   ---- instant_checked_duration_since_nopanic stdout ----
  0.000039
  0.000009   thread 'instant_checked_duration_since_nopanic' (2) panicked at /home/runner/work/miri-test-libstd/miri-test-libstd/rust-src-patched/library/std/src/time.rs:445:33:
  0.000007   overflow when subtracting duration from instant
  0.000006   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  0.000007   note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
```
That's pretty useless.

Also fix the panic message while we are at it.
2026-05-10 03:17:03 +02:00
Matthias Krüger 6fffff97dd Rollup merge of #156107 - Cheese-Space:patch-1, r=Mark-Simulacrum
remove turbofish notation + use None / Some instead of Option:: (in match documentation)
2026-05-10 03:17:03 +02:00
Matthias Krüger 9165dbf12f Rollup merge of #155970 - tomilepp:issue-155968-fix, r=joshtriplett
Add mention of sendfile(2) and splice(2) to fs::copy() documentation.

Fixes rust-lang/rust#155968 by adding mention of sendfile(2) and splice(2) from io::copy()
2026-05-10 03:16:58 +02:00
Matthias Krüger 17977f330e Rollup merge of #149362 - schneems:schneems/get_resolved_envs, r=Mark-Simulacrum
Add Command::get_resolved_envs

This addition allows an end-user to inspect the environment variables that are visible to the process when it boots.

Discussed in:

- Tracking issue: https://github.com/rust-lang/rust/issues/149070 (partially closes)
- ACP: https://github.com/rust-lang/libs-team/issues/194
2026-05-10 03:16:57 +02:00
bors 82bee96507 Auto merge of #155321 - briansmith:b/bufwriter-conservative, r=Mark-Simulacrum
`BufWriter`: Make the soundness of `BorrowedBuf` usage clearer.

The previous safety comment was outdated as it was written before `BorrowedBuf::set_init` was changed to be a boolean. It also failed to address the possibility that `flush_buf` invalidated the assumption.
2026-05-09 18:40:20 +00:00
Tomi Leppikangas f4adc40bbe Add mention of sendfile(2) and splice(2) to fs::copy() documentation.
* Add mention of sendfile(2) and splice(2) to fs::copy() documentation.
* Oxford comma fix
2026-05-09 17:43:33 +00:00
Ralf Jung 773af23505 stream_send_recv_stress tests: wait for threads to finish 2026-05-09 17:37:09 +02:00
bors ffccab6abe Auto merge of #156278 - JonathanBrouwer:rollup-O8O1IcI, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - rust-lang/rust#154025 (Add `keepalive`, `set_keepalive` to `TcpStream` implementations)
 - rust-lang/rust#156024 (CFI: Fix LTO for `#![no_builtins]` crates with CFI)
 - rust-lang/rust#156243 (Move CrateInfo computation after codegen_crate)
 - rust-lang/rust#154846 (Add better default spans for the `Ty` impl of `QueryKey`)
 - rust-lang/rust#155220 (cg_clif: Don't show verbose run-make cmd output for passing tests)
 - rust-lang/rust#156204 (Implemented `PathBuf::into_string`)
 - rust-lang/rust#156245 (Move invocation_temp into OutputFilenames)
 - rust-lang/rust#156250 (add a few new solver normalization tests)
 - rust-lang/rust#156265 (Remove unused `ToStableHashKey` impls.)
2026-05-07 14:59:29 +00:00
Jonathan Brouwer 9d7dfa8254 Rollup merge of #156204 - asder8215:pathbuf_into_string, r=nia-e
Implemented `PathBuf::into_string`

Noticed from this [Zulip chat](https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/.E2.9C.94.20PathBuf.3A.3Ainto_string.3F/with/500962843) that there's been a pretty old [ACP](https://github.com/rust-lang/libs-team/issues/307) on introducing `PathBuf::into_string` that hasn't been implemented yet. I haven't seen anyone link a tracking issue to that [ACP](https://github.com/rust-lang/libs-team/issues/307), so I assume there have been no PRs to complete that ACP.

I made a tracking issue for this ACP [here](https://github.com/rust-lang/rust/issues/156203).
2026-05-07 14:13:54 +02:00
Jonathan Brouwer b1a9484b1e Rollup merge of #154025 - yungcomputerchair:keepalive, r=joboet
Add `keepalive`, `set_keepalive` to `TcpStream` implementations

## What
The current implementation of `TcpStream` does not expose `SO_KEEPALIVE`: rust-lang/rust#69774

## Why
It seems the reason this has not yet been implemented is because the initial implementation went as far as to take the keepalive interval as a parameter. However, Windows does not directly expose these intervals for reading, causing there to be some debate about the shape of the API (see the discussion of this [here](https://github.com/rust-lang/rust/pull/31945#issuecomment-189784913)).

## How
I am proposing that this API is enabled with a `bool` parameter to align with the implementation in both Windows and Unix, as it is the least common denominator between the two of them. With regards to the call to `setsockopt`, [Windows expects a disable/enable](https://learn.microsoft.com/en-us/windows/win32/winsock/so-keepalive), and [Unix does as well](https://man7.org/linux/man-pages/man7/socket.7.html).

The extra configuration for Unix that allows the interval to be tweaked could be done through an additional API perhaps, but I don't think that's stopping us from exposing the switch to at least enable the behavior with the OS defaults.

Tracking issue: rust-lang/rust#155889
2026-05-07 14:13:50 +02:00
Jacob Pratt 99e0e37a2a Rollup merge of #156227 - chaos2007:main, r=jhpratt,randomPoison
Add Trusty OS to the generic error implementation.

Background:
* During this refactor, the Trusty OS was not targeted in the cfg_select: https://github.com/rust-lang/rust/commit/e259373ce9eca5a10201d74a016a4a2e7ab42ed7

r? @randomPoison
2026-05-07 02:12:13 -04:00
Jacob Pratt 746ea544ae Rollup merge of #156177 - RalfJung:windows-time-epoch, r=ChrisDenton
windows/time: avoid being too close to 0

Fixes https://github.com/rust-lang/rust/issues/156142 (but only for Windows -- should we still track it for non-tier-1-platforms?)
2026-05-07 02:12:08 -04:00
Donnie Pollitz 3f7bf606f0 Add Trusty OS to the generic error implementation.
Background:
* During this refactor, the Trusty OS was not targeted in the cfg_select
  https://github.com/rust-lang/rust/commit/e259373ce9eca5a10201d74a016a4a2e7ab42ed7
2026-05-06 11:34:47 +02:00
Jacob Pratt 0092af0ee6 Rollup merge of #156062 - arjunr2:wali-support-clargs, r=nia-e
Added command-line argument support for `wasm32-wali-linux-musl`
2026-05-05 22:50:19 -04:00
Mahdi Ali-Raihan 09b38e43f6 Implemented PathBuf::into_string, which chains PathBuf::into_os_string and OsString::into_string for you 2026-05-05 15:35:57 -04:00
Ralf Jung a07a3b1bf1 windows/time: avoid being too close to 0 2026-05-05 08:44:23 +02:00
Arjun Ramesh 9ef7541f7c Restrict cfg gating on unix to not interfere with emscripten target 2026-05-04 13:43:56 -04:00
Arjun Ramesh f4e1b2f3e8 Use into_bytes directly 2026-05-04 08:34:11 -04:00
Ralf Jung 09dc7fc275 mark some panicking methods around Duration as track_caller 2026-05-04 10:14:02 +02:00
Cheese_space a80af229de remove turbofish notation + use None / Some instead of Option:: 2026-05-03 14:35:33 +02:00
Brian Smith d50c54bd53 BufWriter: Make the soundness of BorrowedBuf usage clearer.
The previous safety comment was outdated as it was written before
`BorrowedBuf::set_init` was changed to be a boolean. It also failed
to address the possibility that `flush_buf` invalidated the
assumption.

Simplify the implementation of `flush_buf` to more obviously preserve
the spare capacity, and document the need to preserve the spare
capacity where necessary.
2026-05-02 11:55:41 -07:00
Guillaume Gomez 50805a9859 Rollup merge of #156063 - WhySoBad:wsaeshutdown-error-kind, r=joshtriplett
Map `WSAESHUTDOWN` to `io::ErrorKind::BrokenPipe`

As discussed in [#t-libs > WSAESHUTDOWN error on Windows](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/WSAESHUTDOWN.20error.20on.20Windows/with/591883531), this adds the mapping for `WSAESHUTDOWN` on Windows to `io::ErrorKind::BrokenPipe`.

r? RalfJung
2026-05-02 04:12:07 +02:00
Josh Triplett e6c358bf66 Typo fix: s/prefect/perfect/ 2026-05-01 16:19:50 -07:00
WhySoBad 3fe9b2ecd3 fix: update comment 2026-05-01 22:48:22 +02:00
Arjun Ramesh a1c5893176 Added std library support for WALI command-line arguments. 2026-05-01 16:29:11 -04:00
WhySoBad 52b3f048cd feat: map WSAESHUTDOWN to BrokenPipe 2026-05-01 22:29:07 +02:00
Austin Henriksen 51e3797ebc bufreader::Buffer: Remove leftover note about initialized field
https://github.com/rust-lang/rust/pull/150129 reworked this field to use `bool` instead of `usize`, which is awesome!
But the field's comment has a leftover note in it which is no longer true, and that needs to be removed.
2026-04-30 23:31:14 -04:00
Gent Semaj 653a8f9020 Add keepalive, set_keepalive to TcpStream implementations 2026-04-30 08:36:18 -07:00
romandev 910e2d2cd0 fix: adding missing corrections 2026-04-28 16:59:56 -03:00
Jacob Pratt f4d64bdd15 Rollup merge of #155854 - cammeresi:20260426-receiver-diag, r=mejrs
Rename the diagnostic item for `std::sync::mpsc::Receiver`

`MpscReceiver` aligns with `MpscSender`.  The original name appears to not actually have been in use, for better or worse.

r? mejrs
2026-04-28 05:37:27 -04:00
Jacob Pratt 1952c34a78 Rollup merge of #155879 - RalfJung:miri-pipes, r=jhpratt
enable pipe tests in Miri
2026-04-28 05:37:24 -04:00
Sidney Cammeresi 04874be3a2 Adjust diagnostic items for mpmc/mpsc Receiver and Sender
`MpscReceiver` aligns with `MpscSender`.  The original name appears to
not actually have been in use, for better or worse.

Along the way, sprinkle the attribute onto `mpmc::Receiver` and
`mpmc::Sender` too.
2026-04-27 17:16:09 -07:00
Ralf Jung 49a490ec09 enable pipe tests in Miri 2026-04-27 15:12:39 +02:00
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