Commit Graph

8056 Commits

Author SHA1 Message Date
Matthias Krüger 243d494350 Rollup merge of #148687 - joboet:nonpoison-hook-rwlock, r=ChrisDenton
std: use a non-poisoning `RwLock` for the panic hook

The code ignored poison errors using `PoisonError` anyway.
2025-11-09 17:37:05 +01:00
bors 20f1c045c4 Auto merge of #148721 - Zalathar:rollup-398va3y, r=Zalathar
Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#128666 (Add `overflow_checks` intrinsic)
 - rust-lang/rust#146305 (Add correct suggestion for multi-references for self type in method)
 - rust-lang/rust#147179 ([DebugInfo] Fix container types failing to find template args)
 - rust-lang/rust#147743 (Show packed field alignment in mir_transform_unaligned_packed_ref)
 - rust-lang/rust#148079 (Rename `downcast_[ref|mut]_unchecked` -> `downcast_unchecked_[ref|mut]`)
 - rust-lang/rust#148084 (Optimize path components iteration on platforms that don't have prefixes)
 - rust-lang/rust#148126 (Fix rust stdlib build failing for VxWorks)
 - rust-lang/rust#148204 (Modify contributor email entries in .mailmap)
 - rust-lang/rust#148279 (rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names)
 - rust-lang/rust#148333 (constify result unwrap unchecked)
 - rust-lang/rust#148539 (Add Allocator proxy impls for Box, Rc, and Arc)
 - rust-lang/rust#148601 (`invalid_atomic_ordering`: also lint `update` & `try_update`)
 - rust-lang/rust#148612 (Add note for identifier with attempted hygiene violation)
 - rust-lang/rust#148613 (Switch hexagon targets to rust-lld)
 - rust-lang/rust#148619 (Enable std locking functions on AIX)
 - rust-lang/rust#148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`)
 - rust-lang/rust#148649 (don't completely reset `HeadUsages`)
 - rust-lang/rust#148673 (Remove a remnant of `dyn*` from the parser)
 - rust-lang/rust#148675 (Remove eslint-js from npm dependencies)
 - rust-lang/rust#148680 (Recover `[T: N]` as `[T; N]`)
 - rust-lang/rust#148688 (Remove unused argument `features` from `eval_config_entry`)
 - rust-lang/rust#148711 (Use the current lint note id when parsing `cfg!()`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-09 08:27:35 +00:00
Stuart Cook 9663de008a Rollup merge of #148619 - amy-kwan:amyk/AddLockingFunctions_AIX, r=workingjubilee
Enable std locking functions on AIX

This patch enables the std locking functions on AIX by including AIX on the list of supported targets for the locking functions. Excluding AIX from the std locking functions results to compilation errors such as: ("try_lock() not supported").
2025-11-09 13:22:32 +11:00
Stuart Cook 5226e15770 Rollup merge of #148126 - hax0kartik:vx-fix-148125, r=Mark-Simulacrum
Fix rust stdlib build failing for VxWorks

Fixes rust-lang/rust#148125.

O_NOFOLLOW is not supported on VxWorks. All the other defines/functions have been added to libc(https://github.com/rust-lang/libc/commit/0cd50326719a4eb541e39f24e871f7b1f54fb035)
2025-11-09 13:22:27 +11:00
Stuart Cook 1ad9e955a8 Rollup merge of #148084 - the8472:prefixless-path-components-iter, r=Mark-Simulacrum
Optimize path components iteration on platforms that don't have prefixes

```
OLD

path::bench_path_components_iter 140.20ns/iter +/- 6.08
path::bench_path_file_name 57.62ns/iter +/- 1.62

NEW

path::bench_path_components_iter 126.74ns/iter +/- 1.46
path::bench_path_file_name 47.48ns/iter +/- 2.49
```
2025-11-09 13:22:26 +11:00
joboet 52fd48c34f std: use a non-poisoning RwLock for the panic hook 2025-11-08 09:27:30 +01:00
Amy Kwan b827732898 Enable std locking functions on AIX
This patch enables the std locking functions on AIX by including AIX on the list
of supported targets for the locking functions. Excluding AIX from the std
locking functions results to compilation errors such as: ("try_lock() not supported").
2025-11-07 04:36:12 +00:00
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 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
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 813072186c)
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
hax0kartik abd9fb44e0 O_NOFOLLOW is not supported on VxWorks 2025-10-26 12:28:48 +05:30
The 8472 d263ab36de replace u8 iterator with slice matching 2025-10-25 14:46:59 +02:00
The 8472 ea3a4e714e skip some Path prefix-component logic on platforms that don't have prefixes 2025-10-25 14:46:59 +02:00
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 066023e47c.
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
Scott Schafer 12f6b9697f chore: Update typos to 1.38.1 2025-10-20 12:20:15 -06:00
David Carlier 4333e72715 std::thread::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