Commit Graph

7993 Commits

Author SHA1 Message Date
Samuel Tardieu
6a9f223f00 Add diagnostic items for Clippy 2025-06-20 17:53:09 +02:00
Trevor Gross
e381a14b7c Rollup merge of #141990 - Qelxiros:141975-unix_send_signal, r=ChrisDenton,tgross35
Implement send_signal for unix child processes

Tracking issue: rust-lang/rust#141975

There are two main differences between my implementation and the Public API section of the tracking issue. ~First, `send_signal` requires a mutable reference, like `Child::kill`.~ Second, `ChildExt` has `Sealed` as a supertrait, bringing it more in line with other extension traits like `CommandExt`.

try-job: `dist-various*`
try-job: `test-various*`
2025-06-20 02:50:38 -04:00
Ed Page
977752fb01 docs(fs): Touch up grammar on lock api 2025-06-19 20:39:54 -05:00
bors
8de4c7234d Auto merge of #141864 - Berrysoft:cygwin-path, r=ChrisDenton
Handle win32 separator for cygwin paths

This PR handles a issue that cygwin actually supports Win32 path, so we need to handle the Win32 prefix and separaters.

r? `@mati865`

cc `@jeremyd2019`

~~Not sure if I should handle the prefix like the windows target... Cygwin *does* support win32 paths directly going through the APIs, but I think it's not the recommended way.~~

Here I just use `cygwin_conv_path` because it handles both cygwin and win32 paths correctly and convert them into absolute POSIX paths.

UPDATE: Windows path prefix is handled.
2025-06-19 13:38:37 +00:00
Trevor Gross
965d260094 Rollup merge of #142654 - workingjubilee:increase-timeout-factor-on-mpmc-test, r=joshtriplett
library: Increase timeout on mpmc test to reduce flakes

This recently spuriously failed in a rollup, so I think we can afford to increase the base timeout and the amount of time slept for to provide a much wider margin for the timeout to be reached.
2025-06-18 20:22:51 -04:00
Jeremy Smart
b3914945ae add ChildExt(::send_signal) 2025-06-18 00:38:55 -04:00
Jubilee Young
66e056a3a7 library: Increase timeout on mpmc test to reduce flakes
This recently spuriously failed in a rollup, so I think we can afford to
increase the base timeout and the amount of time slept for to provide
a much wider margin for the timeout to be reached.
2025-06-17 16:10:37 -07:00
Jacob Pratt
b5fcc90fd7 Rollup merge of #142517 - ChrisDenton:anon-pipe, r=Mark-Simulacrum
Windows: Use anonymous pipes in Command

When setting `Stdio::pipe` on `Command` we want to create an anonymous pipe that can be used asynchronously (at least on our end). Usually we'd use [`CreatePipe`](https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-createpipe) to open anonymous pipes but unfortunately it opens pipes for synchronous access. The alternative is to use [`CreateNamedPipeW`](https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-createnamedpipew) which does allow asynchronous access but that requires giving a file name to the pipe. So we currently have this awful hack where we attempt to emulate anonymous pipes using `CreateNamedPipeW` by attempting to create a unique name and looping until we find one that doesn't already exist.

The better option is to use the lower level [`NtCreateNamedPipeFile`](https://learn.microsoft.com/en-us/windows/win32/devnotes/nt-create-named-pipe-file) (which is used internally by both `CreatePipe` and `CreateNamedPipeW`). This function wasn't documented until a few years ago but now that it is it's ok for us to use it.

try-job: *msvc*
try-job: *mingw*
2025-06-17 23:19:34 +02:00
Jakub Beránek
6092c1a074 Rollup merge of #142236 - yotamofek:pr/std/pathbuf-extend-docs, r=tgross35
Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls

I think it's not very obvious that `PathBuf`'s `Extend` and `FromIterator` impls work like `PathBuf::push`, so I think these should be documented.
I'm not very happy with the wording and examples, open to suggestions :)
2025-06-16 14:31:10 +02:00
Yotam Ofek
45bbb3dfbf Add documentation for PathBuf's FromIterator and Extend impls 2025-06-16 07:49:27 +00:00
Michał Łowicki
426ab14250 Set MSG_NOSIGNAL for UnixSteam
https://github.com/rust-lang/rust/issues/139956

fix
2025-06-16 09:15:17 +02:00
王宇逸
3cb0cba054 Handle win32 separator & prefixes for cygwin paths 2025-06-16 09:24:07 +08:00
Chris Denton
0e1db54b7e Windows: Use anonymous pipes in Command 2025-06-15 16:56:50 +00:00
Christopher Berner
38712030ca Stabilize "file_lock" feature 2025-06-15 06:44:46 -07:00
Matthias Krüger
8f90d05657 Rollup merge of #141493 - tamird:addreskind-bytestr, r=joshtriplett
Delegate `<SocketAddr as Debug>` to `ByteStr`

This allows UTF-8 characters to be printed without escapes, rather than
just ASCII.

r? ``@joshtriplett``
2025-06-14 11:27:10 +02:00
Jubilee
63631fbd75 Rollup merge of #142452 - ChrisDenton:intermittent, r=Noratrieb
Remove "intermittent" wording from `ReadDir`

`ReadDir` claims that `next` will return an error "if there’s some sort of intermittent IO error during iteration". I'm really not sure what this was intended to mean but the implementations will simply return all OS errors encountered during iteration to the user. What else can they do?

This is technically a change in the documented API but seeing as how it doesn't bear any relationship with the implementation I don't think it needs a libs-api fcp.
2025-06-13 20:59:20 -07:00
Chris Denton
595e88ae7d Windows: make read_dir stop iterating on error 2025-06-13 09:49:48 +00:00
Chris Denton
ae645fc0b8 Remove "intermittent" wording from ReadDir 2025-06-13 09:14:15 +00:00
Matthias Krüger
71490fff31 Rollup merge of #142308 - tgross35:upgrade-library-object, r=Mark-Simulacrum
Upgrade `object`, `addr2line`, and `unwinding` in the standard library

Object:

0.37.0 is a semver-breaking release but the only breakage is in `elf::R_RISCV_GNU_*` and `pe::IMAGE_WEAK_EXTERN_*` constants, as well as Mach-O dyld. This API is not used by `std`, so we should be fine to upgrade.

This new version also includes functionality for parsing Wasm object files that we may eventually like to make use of.

Changelog: https://github.com/gimli-rs/object/blob/master/CHANGELOG.md#0370

Addr2line:

0.25.0 is a breaking change only because it upgrades the `gimli` version. It also includes a change to the `compiler-builtins` dependency that helps with [1].

Changelog: https://github.com/gimli-rs/addr2line/blob/master/CHANGELOG.md#0250-20250611

[1]: https://github.com/rust-lang/rust/issues/142265
2025-06-13 05:19:18 +02:00
Tamir Duberstein
ded2afcb23 Delegate <SocketAddr as Debug> to ByteStr
This allows UTF-8 characters to be printed without escapes, rather than
just ASCII.
2025-06-12 19:08:48 -04:00
Trevor Gross
1f6abbb99f Upgrade the standard library addr2line version
0.25.0 is a breaking change only because it upgrades the `gimli`
version. It also includes a change to the `compiler-builtins` dependency
that helps with [1].

Changelog: https://github.com/gimli-rs/addr2line/blob/master/CHANGELOG.md#0250-20250611

[1]: https://github.com/rust-lang/rust/issues/142265
2025-06-11 17:06:53 +00:00
Trevor Gross
1ec80452b6 Upgrade the standard library object version
0.37.0 is a semver-breaking release but the only breakage is in
`elf::R_RISCV_GNU_*` and `pe::IMAGE_WEAK_EXTERN_*` constants, as well as
Mach-O dyld. This API is not used by `std`, so we should be fine to
upgrade.

This new version also includes functionality for parsing Wasm object
files that we may eventually like to make use of.

Also includes the minor bump from 0.37.0 to 0.37.1 to help [1].

Changelog: https://github.com/gimli-rs/object/blob/master/CHANGELOG.md#0370

[1]: https://github.com/rust-lang/rust/issues/142265
2025-06-11 17:01:08 +00:00
David Carlier
1bbabb7ff7 std::net: adding unix_socket_exclbind feature for solaris/illumos.
allows to have a tigher control over the binding exclusivness of the
socket.
2025-06-10 19:44:45 +01:00
León Orell Valerian Liehr
590f630ec6 Rollup merge of #142102 - kiseitai3:141714_stdin_read_to_string_docs, r=tgross35
docs: Small clarification on the usage of read_to_string and read_to_end trait methods

Small clarification on the usage of read_to_string and read_to_end trait methods. The goal is to make it clear that these trait methods will become locked up if attempting to read to the end of stdin (which is a bit non-sensical unless the other end closes the pipe).

Fixes: rust-lang/rust#141714
2025-06-10 16:54:49 +02:00
kiseitai3
7d7fedbab4 docs: Small clarification on the usage of read_to_string and read_to_end trait methods 2025-06-10 05:08:39 +00:00
bors
c6768de2d6 Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJung
Enable Non-determinism of float operations in Miri and change std tests

Links to [#4208](https://github.com/rust-lang/miri/issues/4208) and [#3555](https://github.com/rust-lang/miri/issues/3555) in Miri.

Non-determinism of floating point operations was disabled in rust-lang/rust#137594 because it breaks the tests and doc-tests in core/coretests and std. This PR enables some of them.

This pr includes the following changes:

- Enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP
- These operations now have a fixed output based on the C23 standard, except the pow operations, this is tracked in [#4286](https://github.com/rust-lang/miri/issues/4286#issue-3010677983)
- Changes tests that made incorrect assumptions about the operations, not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`.
- Changed the doctests of the stdlib of these operations to compare against fixed constants instead of `f*::EPSILON`, which now succeed with Miri and `-Zmiri-many-seeds`
- Added a constant `APPROX_DELTA` in `std/tests/floats/f32.rs` which is used for approximation tests, but with a different value when run in Miri. This is to make these tests succeed.
- Added tests in the float tests of Miri to test the C23 behaviour.

Fixes https://github.com/rust-lang/miri/issues/4208
2025-06-09 21:21:58 +00:00
Trevor Gross
fd06f6d658 Rollup merge of #142238 - RalfJung:nonnull_provenance, r=workingjubilee
stabilize nonnull_provenance

Fixes https://github.com/rust-lang/rust/issues/135243
FCP passed in https://github.com/rust-lang/rust/issues/135243
2025-06-09 12:17:55 -05:00
Trevor Gross
ab87ed150b Rollup merge of #141993 - tgross35:use-in-tree-builtins, r=bjorn3
Use the in-tree `compiler-builtins` for the sysroot

Many of `std`'s dependency have a dependency on the crates.io `compiler-builtins` when used with the feature `rustc-std-workspace-core`. Use a Cargo patch to select the in-tree version instead.

`compiler-builtins` is also added as a dependency of `rustc-std-workspace-core` so these crates can remove their crates.io dependency in the future.

Zulip discussion: [#t-compiler > Using in-tree compiler-builtins](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20in-tree.20compiler-builtins/with/522445336)

Once this merges, the following PRs will need to make it to a release for the relevant crates:

- https://github.com/rust-lang/getopts/pull/119 (can merge at any time)
- https://github.com/rust-lang/hashbrown/pull/625 (can merge at any time)
- https://github.com/rust-lang/stdarch/pull/1825
- https://github.com/rust-lang/rustc-demangle/pull/80
- https://github.com/rust-lang/cfg-if/pull/84
- https://github.com/unicode-rs/unicode-width/pull/77

The above should cover all tier 1 targets with no `std` features enabled. The remaining cover the rest:

- https://github.com/alexcrichton/dlmalloc-rs/pull/50 (wasm, xous, sgx)
- https://github.com/gimli-rs/gimli/pull/769
- https://github.com/r-efi/r-efi/pull/89 (efi)
- https://github.com/r-efi/r-efi-alloc/pull/9 (efi)
- https://github.com/fortanix/rust-sgx/pull/770 (sgx)
- https://github.com/hermit-os/hermit-rs/pull/718 (hermit)
- https://github.com/bytecodealliance/wasi-rs/pull/108 (wasi)
- https://github.com/gimli-rs/addr2line/pull/345
- https://github.com/oyvindln/adler2/pull/2
- https://github.com/BurntSushi/memchr/pull/180
- https://github.com/Frommi/miniz_oxide/pull/173
- https://github.com/gimli-rs/object/pull/777

try-job: x86_64-gnu
try-job: test-various
2025-06-09 12:17:53 -05:00
bors
14863ea077 Auto merge of #142242 - matthiaskrgr:rollup-1sgx0ji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#129121 (Stabilize `tcp_quickack`)
 - rust-lang/rust#142192 (De-duplicate f16 & f128 doctest attributes)
 - rust-lang/rust#142193 (add tests for pattern binding drop order edge cases)
 - rust-lang/rust#142222 (Dont make `ObligationCtxt`s with diagnostics unnecessarily)
 - rust-lang/rust#142228 (rustc-dev-guide subtree update)
 - rust-lang/rust#142231 (Run `calculate_matrix` job on `master` to cache citool builds)
 - rust-lang/rust#142232 (add `Cargo.lock` to CI-rustc allowed list for non-CI env)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-09 12:21:14 +00:00
Matthias Krüger
25de98fd41 Rollup merge of #142192 - Urgau:dedup-f16-f128-test-attrs, r=tgross35
De-duplicate f16 & f128 doctest attributes

Now that rustdoc supports `#[doc(test(attr(...)))]` at every level, thanks to https://github.com/rust-lang/rust/pull/140560, we can de-duplicate the f16 & f128 doctest attributes.

Unfortunately we can de-duplicate the `cfg`s attribute as rustdoc would complain about missing `main`, but it's already much better than before.

Addresses https://github.com/rust-lang/rust/pull/140323/files#r2062702761
r? `@tgross35`
2025-06-09 13:55:33 +02:00
Matthias Krüger
d9563a5aa4 Rollup merge of #129121 - devnexen:stabilize_ext_linux_tcp_layer, r=tgross35
Stabilize `tcp_quickack`

to stabilise the quickack part for now, tcp_deferaccept had been added at a later stage.

The related API calls are the following

```rust
// std::os::linux::net

// sealed trait, implemented for std::net::TcpStream
pub trait TcpStreamExt: Sealed{
  fn quickack(&self) -> io::Result<bool>;
  fn set_quickack(&self, quickack: bool) -> io::Result<()>;
}
```

Closes: https://github.com/rust-lang/rust/issues/96256
2025-06-09 13:55:32 +02:00
Ralf Jung
3164ca8bb4 stabilize nonnull_provenance 2025-06-09 12:36:24 +02:00
Matthias Krüger
bf17f139d3 Rollup merge of #142224 - joshtriplett:remove-gratuitous-wait-in-stress-test, r=workingjubilee
Avoid a gratuitous 10s wait in a stress test

`stress_recv_timeout_two_threads`, in the mpmc and mpsc testsuites, is a stress test of the `recv_timeout` function. This test processes and ignores timeouts, and just ensures that every sent value gets received. As such, the exact length of the timeouts is not critical, only that the timeout and sleep durations ensure that at least one timeout occurred.

The current tests have 100 iterations, half of which sleep for 200ms, causing the test to take 10s. This represents around 2/3rds of the *total* runtime of the `library/std` testsuite, and is the only standard library test that takes more than a second.

Reduce this to 50 iterations where half of them sleep for 10ms, causing the test to take 0.25s.

Add a check that at least one timeout occurred.
2025-06-09 10:20:54 +02:00
Josh Triplett
889f7cbffa Avoid a gratuitous 10s wait in a stress test
`stress_recv_timeout_two_threads`, in the mpmc and mpsc testsuites,
is a stress test of the `recv_timeout` function. This test processes and
ignores timeouts, and just ensures that every sent value gets received.
As such, the exact length of the timeouts is not critical, only that
the timeout and sleep durations ensure that at least one timeout
occurred.

The current tests have 100 iterations, half of which sleep for 200ms,
causing the test to take 10s. This represents around 2/3rds of the
*total* runtime of the `library/std` testsuite.

Reduce this to 50 iterations where half of them sleep for 10ms, causing
the test to take 0.25s.

Add a check that at least one timeout occurred.
2025-06-08 20:22:07 -07:00
Jubilee
840baa46ff Rollup merge of #142053 - heiher:loong32-none, r=wesleywiser
Add new Tier-3 targets: `loongarch32-unknown-none*`

MCP: https://github.com/rust-lang/compiler-team/issues/865

NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-08 17:17:53 -07:00
Urgau
fdae3448ba De-duplicate f16 & f128 doctest attributes 2025-06-08 14:51:13 +02:00
Trevor Gross
cc3e57147e Use the in-tree compiler-builtins
Many of `std`'s dependency have a dependency on the crates.io
`compiler-builtins` when used with the feature
`rustc-std-workspace-core`. Use a Cargo patch to select the in-tree
version instead.

`compiler-builtins` is also added as a dependency of
`rustc-std-workspace-core` so these crates can remove their crates.io
dependency in the future.
2025-06-08 02:36:58 +00:00
Jacob Pratt
06a2daf4db Rollup merge of #137992 - its-the-shrimp:stabilise_os_string_pathbuf_leak, r=dtolnay
Stabilise `os_string_pathbuf_leak`

This PR stabilises `#[feature(os_string_pathbuf_leak)]`, which defines 2 new methods in the std:

```rs
impl OsString {
    pub fn leak<'a>(self) -> &'a mut OsStr;
}

impl PathBuf {
    pub fn leak<'a>(self) -> &'a mut Path;
}
```

ACP: https://github.com/rust-lang/libs-team/issues/389
Tracking issue: https://github.com/rust-lang/rust/issues/125965
Implementation: https://github.com/rust-lang/rust/pull/125966
2025-06-07 07:05:44 +02:00
Guillaume Gomez
15d9b9619c Rollup merge of #141471 - RalfJung:unsafe-fn-in-trait, r=traviscross
unsafe keyword docs: emphasize that an unsafe fn in a trait does not get to choose its safety contract

Inspired by discussion in https://github.com/rust-lang/rust/issues/139368.
Cc `@hanna-kruppe`
2025-06-06 23:53:16 +02:00
Guillaume Gomez
3fee6cccde Rollup merge of #140418 - tgross35:std-c-size_t, r=workingjubilee
Reexport types from `c_size_t` in `std`

These are unstably available in `core` and should be in `std` too, but are not currently reexported. Resolve this here.

Tracking issue: https://github.com/rust-lang/rust/issues/88345
2025-06-06 23:53:15 +02:00
Ralf Jung
910a59dfae unsafe keyword docs: emphasize that an unsafe fn in a trait does not get to choose its safety contract 2025-06-06 22:34:10 +02:00
schvv31n
eba3a61067 Stabilised os_string_pathbuf_leak 2025-06-06 12:06:42 -07:00
Ayush Singh
669564d028 std: sys: random: uefi: Provide rdrand based fallback
Some UEFI systems based on American Megatrends Inc. v3.3 do not provide
RNG support [1]. So fallback to rdrand in such cases.

[1]: https://github.com/rust-lang/rust/issues/138252#issuecomment-2891270323

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-06-06 10:14:08 +05:30
WANG Rui
38d69c3f57 Add new Tier-3 targets: loongarch32-unknown-none*
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06 08:19:38 +08:00
Matthias Krüger
9c895558ec Rollup merge of #142091 - thaliaarchi:aix-getenv, r=workingjubilee
Fix AIX build

Fix rust-lang/rust#141543.

`getenv` was moved out of this file to `sys::env::getenv` in rust-lang/rust#140143. Replace its usage with `std::env::var_os`, the publicly exposed version. This matches the other usages of the same function in this file.
2025-06-06 00:58:48 +02:00
Thalia Archibald
46ce08ef06 Fix AIX build 2025-06-05 10:29:50 -07:00
Tobias Bucher
4b1e28b21f Clarify description of Seek::stream_len
It can only describe the inner workings of the default implementation,
other implementations might not be implemented using seeks at all.
2025-06-05 16:27:28 +02:00
Tobias Bucher
fde8a8d518 Optimize Seek::stream_len impl for File
It uses the file metadata on Unix with a fallback for files incorrectly
reported as zero-sized. It uses `GetFileSizeEx` on Windows.

This reduces the number of syscalls needed for determining the file size
of an open file from 3 to 1.
2025-06-05 16:27:27 +02:00
LorrensP-2158466
00452bd783 change tests to use fixed constants to let them pass with miri 2025-06-05 16:22:13 +02:00
Matthias Krüger
88620b400e Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=Amanieu
make `OsString::new` and `PathBuf::new` unstably const

Since #129041, `String::into_bytes` is `const`, which allows making `OsString::new` and `PathBuf::new` unstably const now.
Not sure what the exact process for this is; does it need an ACP?
2025-06-04 07:54:33 +02:00