Commit Graph

9142 Commits

Author SHA1 Message Date
John Millikin 7bf5fe7bf8 Add ChildExt::kill_process_group
This function wraps POSIX `killpg(pid, SIGKILL)`, and on Linux
additionally may be implemented by `pidfd_send_signal`.
2026-05-13 22:39:57 +09:00
John Millikin 2c30279ff6 Add send_process_group_signal to existing unix_send_signal feature
This function wraps POSIX `killpg()`, and on Linux additionally
may be implemented by `pidfd_send_signal`.
2026-05-13 19:41:14 +09:00
Jonathan Brouwer ac656cbf21 Rollup merge of #156431 - bushrat011899:core_io_util, r=nia-e
Move `std::io::util` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Subset of: https://github.com/rust-lang/rust/pull/154684

## Description

Moves utility types and functions from `std::io::util` and `std::io` to `core::io`, leaving any IO trait implementations behind. They will be moved along with the traits themselves. Certain documentation links had to be amended.

- `Chain`
- `Empty`
- `Repeat`
- `Sink`
- `Take`
- `empty`
- `repeat`
- `sink`

---

## Notes

* This can be reviewed independently of the other PRs tracked in rust-lang/rust#154046.
* `Chain` and `Take` were previously in the main `mod.rs` file for `std::io`, but I've chosen to move them into the `util.rs` file in `core::io` instead. I think they make more sense in that file, but I'm happy to move them into `mod.rs` if that's a controversial decision.
* No AI tooling of any kind was used during the creation of this PR.
2026-05-12 18:53:37 +02:00
Jonathan Brouwer 5a38b67a02 Rollup merge of #156428 - bushrat011899:core_io_cursor, r=nia-e
Move `std::io::Cursor` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Subset of: https://github.com/rust-lang/rust/pull/154684

## Description

Moves `std::io::Cursor` to `core::io`, leaving the IO trait implementations behind. They will be moved along with the traits themselves. Certain documentation links had to be amended, and a private/unstable `into_parts_mut` method was added to allow the internals to remain private.

---

## Notes

* This can be reviewed independently of the other PRs tracked in rust-lang/rust#154046.
* No AI tooling of any kind was used during the creation of this PR.
2026-05-12 18:53:36 +02:00
Zac Harrold 5cbf9f8c8b Move std::io::util to core::io 2026-05-12 23:07:34 +10:00
Zac Harrold e9125c62b1 Move std::io::Cursor into core::io 2026-05-12 22:59:37 +10:00
Jonathan Brouwer 8cfae220da Rollup merge of #156393 - RalfJung:core-miri-tests, r=tgross35
enable more f16/f128 tests in Miri

See the individual commit messages for details.

The last commit is a drive-by comment fix that was not worth its own PR.
r? @tgross35
2026-05-12 07:03:55 +02:00
Ralf Jung d6df0b0b57 enable f16/f128 doctests in Miri 2026-05-11 22:42:46 +02:00
Jonathan Brouwer bd479badfb Rollup merge of #156392 - Wilfred:float_ceil_docs, r=Mark-Simulacrum
Improve doc comments for f32::ceil() and f32::floor()

Previously ::floor() included an example showing behaviour for negative values, but ::ceil() did not. Ensure both have examples of the negative case, for both f32 and f64.

Whilst we're here, tweak the wording slightly so it reads better.
2026-05-11 10:29:20 +02:00
Jonathan Brouwer 4f22db3e86 Rollup merge of #156375 - RalfJung:kernel_copy-background-threads, r=Mark-Simulacrum
kernel_copy tests: properly join background threads

This helps Miri because when there are threads just hanging in the background, we cannot check for memory leaks.

I think even without Miri this currently leads to 100% CPU load on one core for each of these threads: once the test function returns and `sink` gets dropped, the `read` in the thread will always immediately return `0`, and then we just loop with that forever until the process exits.
2026-05-11 10:29:16 +02:00
Jonathan Brouwer 5e230f5de6 Rollup merge of #156389 - RalfJung:miri-fs, r=Mark-Simulacrum
prepare fs tests for miri

- reduce iteration counts to get rid of timeouts
- disable one test that relies on spawning processes
2026-05-11 10:29:14 +02:00
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
Wilfred Hughes e8eb80b9de Improve doc comments for f32::ceil() and f32::floor()
Previously ::floor() included an example showing behaviour for
negative values, but ::ceil() did not. Ensure both have examples of
the negative case, for both f32 and f64.

Whilst we're here, tweak the wording slightly so it reads better.
2026-05-10 12:25:39 +01:00
Ralf Jung 5901bb8d2d remove some miri test gates 2026-05-10 12:45:15 +02:00
Ralf Jung d1c3e91a7e prepare fs tests for miri 2026-05-10 12:03:47 +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
Ralf Jung e35d0affe7 kernel_copy tests: properly join background threads 2026-05-09 23:31:18 +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