8461 Commits

Author SHA1 Message Date
Folkert de Vries
c59298da36
stabilize stdarch_s390x_feature_detection 2025-11-06 12:49:46 +01:00
Stuart Cook
6e03719029
Rollup merge of #148495 - ChrisDenton:path_is_empty, r=workingjubilee
Implement Path::is_empty

This implements `Path::is_empty` which is simply a convenience wrapper for `path.as_os_str().is_empty()`.

Tracking issue: https://github.com/rust-lang/rust/issues/148494
ACP: https://github.com/rust-lang/libs-team/issues/687
2025-11-05 10:59:20 +11:00
Chris Denton
7e66d6c3b9
Implement Path::is_empty 2025-11-04 19:23:51 +00:00
Stuart Cook
5eef85cc9b
Rollup merge of #146301 - Ayush1325:uefi-box, r=joboet
library: std: sys: net: uefi: tcp: Implement write_vectored

- A working vectored write implementation for TCP4.
- Also introduces a small helper UefiBox intended to be used with heap allocated UEFI DSTs.
- Tested on OVMF

cc ```@nicholasbishop```
2025-11-04 13:44:49 +11:00
Guillaume Gomez
871692a278
Rollup merge of #148378 - ilai-deutel:update_hook-doc, r=joboet
Fix documentation for std::panic::update_hook

The equivalent code given in the documentation of `std::panic::update_hook`[^1] does not compile:

* `set_hook` expects a boxed function
* Missing closing delimiter for the closure

[^1]: rust-lang/rust#92649
2025-11-03 17:20:38 +01:00
Matthias Krüger
0a9018b919
Rollup merge of #148135 - hax0kartik:fix-vx-unix-sock, r=Mark-Simulacrum
Ignore unix socket related tests for VxWorks

Unix Sockets are not implemented in VxWorks, and therefore, ignore testcases related to UnixDatagram, UnixListener and UnixStream.
2025-11-02 20:21:02 +01:00
Matthias Krüger
2afb64ed71
Rollup merge of #148026 - joboet:dont-leak-thread-closure, r=Mark-Simulacrum
std: don't leak the thread closure if destroying the thread attributes fails

The comment about double-free is wrong – we can safely drop both the thread attributes and the thread closure. Here, I've used `DropGuard` for the attributes and moved the `Box::into_raw` to just before the `pthread_create`.
2025-11-02 20:21:01 +01:00
Ilaï Deutel
b9e127a830 Fix documentation for std::panic::update_hook
* `set_hook` expects a boxed function
* Missing closing delimiter for the closure
2025-11-01 23:46:35 -04:00
Ayush Singh
471f2ba64e
library: std: sys: net: uefi: tcp: Implement write_vectored
- A working vectored write implementation for TCP4.
- Also introduces a small helper UefiBox intended to be used with heap
  allocated UEFI DSTs.
- Tested on OVMF

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-11-02 00:23:21 +05:30
bors
fca2e941f8 Auto merge of #148356 - matthiaskrgr:rollup-mh4l2yi, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#135602 (Tweak output of missing lifetime on associated type)
 - rust-lang/rust#139751 (Implement pin-project in pattern matching for `&pin mut|const T`)
 - rust-lang/rust#142682 (Update bundled musl to 1.2.5)
 - rust-lang/rust#148171 (Simplify code to generate line numbers in highlight)
 - rust-lang/rust#148263 (Unpin `libc` and `rustix` in `compiler` and `rustbook`)
 - rust-lang/rust#148301 ([rustdoc search] Include extern crates when filtering on `import`)
 - rust-lang/rust#148330 (Don't require dlltool with the dummy backend on MinGW)
 - rust-lang/rust#148338 (cleanup: upstream dropped amx-transpose functionality)
 - rust-lang/rust#148340 (Clippy subtree update)
 - rust-lang/rust#148343 (`nonpoison::Condvar` should take `MutexGuard` by reference)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-01 16:44:42 +00:00
Connor Tsui
c1153b08ff
move condvar test from mutex to condvar test file
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:53:39 -04:00
Connor Tsui
3d5a40809c
update nonpoison::Condvar to take guards by reference
Since non-poisoning `Condvar` take non-poisoing `Mutex`es when
`wait`ing, we do not need to take by ownership since a poison error
cannot occur while we wait.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:53:33 -04:00
Connor Tsui
7069400c47
revert combined nonpoison/poison tests for condvar
Setup for writing different tests for the `nonpoison::Condvar` since it
will have a different API.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-31 15:31:53 -04:00
Matthias Krüger
eaa283deca
Rollup merge of #148322 - oxidecomputer:ea-flock-illumos, r=ChrisDenton
Enable file locking support in illumos

https://github.com/rust-lang/rust/pull/132977 introduced an allow-list of targets supporting file locking, but forgot to add illumos to it (which introduced support for it in ~2015). `File::lock` and friends are now stable, and the ecosystem is slowly replacing custom libc calls with the standard library. Crucially, in 1.91 both Cargo and bootstrap switched to `File::lock`, both breaking build directory locking.

This PR enables file locking on illumos. Fixes https://github.com/rust-lang/rust/issues/146312.
2025-10-31 18:41:52 +01:00
Matthias Krüger
c438dbd035
Rollup merge of #147986 - jesseschalken:use-fstatat-macos, r=joboet
Use fstatat() in DirEntry::metadata on Apple platforms

Apple supports `fstatat` on macOS >=10.10 ([source](https://gitlab.gnome.org/GNOME/glib/-/issues/2203)), and according to [Platform Support](https://doc.rust-lang.org/beta/rustc/platform-support.html) the oldest supported version is 10.12.

Google says iOS >=10 supports `fstatat` but doesn't provide a source. [*-apple-ios](https://doc.rust-lang.org/beta/rustc/platform-support/apple-ios.html#os-version) says the minimum supported iOS version is 10.0.

Unsure about tvOS, watchOS and visionOS, hoping CI can confirm this.

I am testing with [fastdu](https://github.com/jesseschalken/fastdu) which is effectively a stress test for `DirEntry::metadata`. In one test this provides a **1.13x** speedup.

```
$ hyperfine --warmup 1 'target/release/fastdu testdir' 'fastdu testdir'
Benchmark 1: target/release/fastdu testdir
  Time (mean ± σ):     154.6 ms ±  17.4 ms    [User: 31.7 ms, System: 187.6 ms]
  Range (min … max):   148.4 ms … 225.5 ms    19 runs

Benchmark 2: fastdu testdir
  Time (mean ± σ):     175.3 ms ±  15.8 ms    [User: 50.0 ms, System: 196.2 ms]
  Range (min … max):   165.4 ms … 211.7 ms    17 runs

Summary
  target/release/fastdu testdir ran
    1.13 ± 0.16 times faster than fastdu testdir
```

You can also reproduce a speedup with a program like this (providing a directory with many entries):

```rust
fn main() {
    let args: Vec<_> = std::env::args_os().collect();
    let dir: PathBuf = args[1].clone().into();

    for entry in dir.read_dir().as_mut().unwrap() {
        let entry = entry.as_ref().unwrap();
        let metadata = entry.metadata();
        let metadata = metadata.as_ref().unwrap();
        println!("{} {}", metadata.len(), entry.file_name().display());
    }
}
```

```
$ hyperfine './target/release/main testdir' './main testdir'
Benchmark 1: ./target/release/main testdir
  Time (mean ± σ):     148.3 ms ±   5.2 ms    [User: 23.1 ms, System: 122.9 ms]
  Range (min … max):   145.2 ms … 167.2 ms    19 runs

Benchmark 2: ./main testdir
  Time (mean ± σ):     164.4 ms ±   9.5 ms    [User: 32.6 ms, System: 128.8 ms]
  Range (min … max):   158.5 ms … 199.5 ms    17 runs

Summary
  ./target/release/main testdir ran
    1.11 ± 0.07 times faster than ./main testdir
```
2025-10-31 18:41:50 +01:00
Emily Albini
3d9c69b594 enable flock for illumos 2025-10-31 12:41:54 +01:00
Josh Stone
f25ca45fd1 Update CURRENT_RUSTC_VERSION post-bump
(cherry picked from commit 813072186c1c305ea62c7270f1514dfab5166af2)
2025-10-28 13:22:00 -07:00
hax0kartik
ff138802a0 Ignore unix socket related tests on VxWorks 2025-10-26 15:45:24 +05:30
Mads Marquart
66b992d705 Fix compiling CondVar::wait_timeout on 32-bit Apple platforms 2025-10-24 17:36:05 +02:00
Josh Stone
c01682ebf6 Revert "feat: implement hash_map! macro"
This reverts commit 066023e47c0c92e7edefd60831ce7d6f15f23750.
2025-10-23 12:37:53 -07:00
Josh Stone
a81ed52f58 Add a regression test for rust-lang/rust#147971 2025-10-23 12:37:53 -07:00
joboet
a7f08dec43
std: don't leak the thread closure if destroying the thread attributes fails 2025-10-23 14:25:31 +02:00
Stuart Cook
e93ec9aab4
Rollup merge of #146629 - joboet:reorganize-weak, r=ibraheemdev
std: reorganize the UNIX-internal `weak` module

This moves the `dlsym`-based and weak-linkage versions of the `weak!` macro into separate files, both of which include a common test file. As a result, both versions will be tested on all the platforms where they are used.

Since the `#[link_name]` arm of the `dlsym` version was unused, I've removed it. I've also removed the unused `raw_syscall!` and non-Linux `syscall!` macros and gated the `#[allow(dead_code, unused_macros)]` to only apply on non-Linux platforms, so compilation will fail if `weak` turns out to be unused on all platforms.

The last change concerns the use of `dlsym!` on FreeBSD: it is only used once, to link against `sysctlbyname`. But that symbol is always available, so there is no need for weak linkage.
2025-10-23 12:06:31 +11:00
Stuart Cook
e4bf8b3fc3
Rollup merge of #115501 - michaelvanstraten:set_inherit_handles, r=ChrisDenton
Add new inherit_handles flag to CommandExt trait

This PR adds a new flag to the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait to set whether to inherit the handles of the calling process ([ref][1]).

This is necessary when, for example, spawning a process with a `pseudoconsole` attached.

r? ``@ChrisDenton``

ACP: https://github.com/rust-lang/libs-team/issues/264
[1]: <https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw>
2025-10-23 12:06:30 +11:00
Jesse Schalken
fe4c2a202d typo 2025-10-23 00:37:40 +11:00
bors
4d94478977 Auto merge of #147826 - Muscraft:update-typos, r=Noratrieb
Update typos

I saw that `typos` was a few versions out of date and figured it would be a good idea to update it. Upgrading to `1.38.1` adds the [July](https://github.com/crate-ci/typos/issues/1331), [August](https://github.com/crate-ci/typos/issues/1345), and [September](https://github.com/crate-ci/typos/issues/1370) dictionary updates. As part of this change, I also sorted the configuration file.
2025-10-22 13:11:47 +00:00
Jesse Schalken
60a7cab12e Use fstatat() in DirEntry::metadata on Apple platforms 2025-10-23 00:03:48 +11:00
Matthias Krüger
4a117590b7
Rollup merge of #147933 - thaliaarchi:consistent-osstring, r=tgross35
os_str: Make platform docs more consistent

- Port `Buf::as_slice`/`as_mut_slice` wording from wtf8 to bytes
- Make `Buf::extend_from_slice_unchecked` docs more platform-independent
- wtf8 `Buf` was missing `#[repr(transparent)]`
2025-10-22 07:12:12 +02:00
Thalia Archibald
7e2b76e1b6 motor: Use UTF-8 guarantee for OS strings 2025-10-21 16:36:10 -06:00
Thalia Archibald
206ffcc786 os_str: Create UTF-8 platform encoding 2025-10-21 16:29:14 -06:00
Michael van Straten
24b0c27b9a Add new inherit_handles flag to CommandExt trait
This patch adds a new flag to the [`CommandExt`](1) trait to set whether to
inherit the handles of the calling process (2) on Windows systems.

ACP: https://github.com/rust-lang/libs-team/issues/264

[1]: https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html
[2]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
2025-10-21 18:53:46 +02:00
Matthias Krüger
e2110d8463
Rollup merge of #147930 - thaliaarchi:motor-set-times, r=joboet
motor: Add new `set_times` stubs

Motor OS `std` support (https://github.com/rust-lang/rust/pull/147000) and `set_times`/`set_times_nofollow` (https://github.com/rust-lang/rust/pull/147468) were merged around the same time, so Motor OS is missing this API and currently fails to build.

cc `@lasiotus`
2025-10-21 17:26:40 +02:00
Thalia Archibald
b39fb327cb motor: Add new set_times stubs 2025-10-20 21:45:14 -06:00
Thalia Archibald
563302ea9a os_str: Make platform docs more consistent
- Port `Buf::as_slice`/`as_mut_slice` wording from wtf8 to bytes
- Make `Buf::extend_from_slice_unchecked` docs more platform-independent
- wtf8 `Buf` was missing `#[repr(transparent)]`
2025-10-20 21:26:05 -06:00
Stuart Cook
79e46694de
Rollup merge of #147125 - connortsui20:poison-once-remove, r=tgross35
move `once` module out of `poison`

From https://github.com/rust-lang/rust/issues/134645#issuecomment-3324577500, since `Once` will not have a non-poisoning variant, we remove it from the `poison` module.

Additionally:

1. Renames `once::ExclusiveState` to `OnceExclusiveState` since it was a bit confusing reading just `ExclusiveState` where it is used.
2. Reorders a few module definitions and re-exports in `library/std/src/sync/mod.rs` for clarity.

Also, once this is merged, I think that we can begin the process of stabilizing [`sync_poison_mod`](https://github.com/rust-lang/rust/issues/134646)
2025-10-21 12:20:56 +11:00
bors
c7a635f33c Auto merge of #147910 - joboet:wait_timeout-spurious-test, r=ChrisDenton
handle spurious returns of `wait_timeout` in test

Fixes https://github.com/rust-lang/rust/issues/147885
Closes https://github.com/rust-lang/rust/pull/147871

`wait_timeout` is allowed to spuriously return, hence the `timeout_nanoseconds` must not assume that the wakeup resulted from a `notify_all()`.
2025-10-20 22:04:39 +00:00
Scott Schafer
12f6b9697f
chore: Update typos to 1.38.1 2025-10-20 12:20:15 -06:00
joboet
76dfdd4e70
handle spurious returns of wait_timeout in test 2025-10-20 17:53:49 +02:00
David Carlier
4333e72715
std:🧵:available_parallelism() vxworks libc symbol usage. 2025-10-19 05:50:26 +01:00
Matthias Krüger
55a3df8cee
Rollup merge of #147494 - evanj:evan.jones/thread-spawn-link, r=joboet
std::thread spawn: Docs: Link to Builder::spawn; Make same.

Replace "use this API instead" with a link to Builder::spawn. Edit the paragraph to make it slightly clearer.

The Scope::spawn method already included a link to `Builder::spawn_scoped`. Make the docs for `Scope::spawn` and `thread::spawn` nearly the same.
2025-10-18 15:09:03 +02:00
Matthias Krüger
fc6502976c
Rollup merge of #147468 - chenyukang:yukang-api-set-times, r=joshtriplett
Implement fs api set_times and set_times_nofollow

implementation of rust-lang/rust#147455

r? ````@joshtriplett````
2025-10-18 08:08:38 +02:00
Matthias Krüger
b46db5c6b7
Rollup merge of #140153 - thaliaarchi:encode-wide-debug, r=ChrisDenton
Implement `Debug` for `EncodeWide`

Since `std::os::windows::ffi::EncodeWide` was reexported from `std::sys_common::wtf8::EncodeWide`, which has `#![allow(missing_debug_implementations)]` in the parent module, it did not implement `Debug`. When it was moved to `core`, a placeholder impl was added; fill it in.

This becomes insta-stable.

r? libs-api
2025-10-18 08:08:35 +02:00
Connor Tsui
3a9c521285
move once module out of poison
Since `Once` will not have a non-poisoning variant, we remove it from
the `poison` module.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-17 11:43:39 -04:00
Connor Tsui
7b61403c50
reorganize library/std/src/sync/mod.rs file
Moves things around to make a bit more sense (plus prepare moving `once`
out of `poison`.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-17 11:43:38 -04:00
Connor Tsui
0758e191d5
clean up some documentation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-17 11:43:15 -04:00
Connor Tsui
a61c8be269
rename once::ExclusiveState to OnceExclusiveState
It is a bit confusing when reading code that uses this type since it is
not immediately obvious that it is specific to `Once`.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-10-17 10:57:39 -04:00
Matthias Krüger
f337e28bd9
Rollup merge of #147773 - timvisee:docs-empty-is-ascii, r=Noratrieb
`is_ascii` on an empty string or slice returns true

Update the description of the [`is_ascii`](https://doc.rust-lang.org/std/primitive.str.html#method.is_ascii) functions - an empty string or slice also returns `true`.

This follows the pattern of [`all()`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.all). Clippy currently suggests to change `string.chars().all(|c| c.is_ascii())` into `string.is_ascii()`. This suggestion therefore seems fitting.

I've already questioned the behavior for this multiple times. I've always had to check the internals to conclude how it works. That's why I'm opening this PR to add it directly in the documentation.
2025-10-16 19:35:28 +02:00
Matthias Krüger
91f48d8ba7
Rollup merge of #147000 - moturus:motor-os_stdlib_pr, r=tgross35
std: Add Motor OS std library port

Motor OS was added as a no-std Tier-3 target in
[PR 146848](https://github.com/rust-lang/rust/pull/146848) as x86_64-unknown-motor.

This PR adds the std library for Motor OS.

While the PR may seem large, all it does is proxy
std pal calls to [moto-rt](https://crates.io/crates/moto-rt). Where there is some non-trivial
code (e.g. thread::spawn), it is quite similar, often
identical, to what other platforms do.
2025-10-16 19:35:23 +02:00
Evan Jones
c4dc39be05
add link to Builder (code review improvement) 2025-10-16 09:07:57 -04:00
timvisee
7a11c72db0
is_ascii on an empty string or slice returns true 2025-10-16 10:52:51 +02:00