Commit graph

8717 commits

Author SHA1 Message Date
Matthias Krüger
3b1f270742
Rollup merge of #150918 - uefi-fs-seek, r=jhpratt
std: sys: fs: uefi: Implement File::seek

- Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-01-11 09:56:50 +01:00
Matthias Krüger
98270a95ed
Rollup merge of #150862 - uefi-fs-flush, r=the8472
std: sys: fs: uefi: Implement File::flush

- Also forward fsync and datasync to flush. UEFI does not have anything separate for metadata sync.

@rustbot label +O-UEFI
2026-01-11 09:56:49 +01:00
Matthias Krüger
cf4ad6bf68
Rollup merge of #150776 - connect_error-fbsd15, r=Mark-Simulacrum
Fix the connect_error test on FreeBSD 15+

On FreeBSD 15, the error code returned in this situation changed.  It's now ENETUNREACH.  I think that error code is reasonable, and it's documented for connect(2), so we should expect that it might be returned.
2026-01-11 09:56:39 +01:00
Matthias Krüger
7a9ef99a56
Rollup merge of #150668 - stdio-swap, r=Mark-Simulacrum,RalfJung
Unix implementation for stdio set/take/replace

Tracking issue: https://github.com/rust-lang/rust/issues/150667
ACP: https://github.com/rust-lang/libs-team/issues/500
2026-01-11 09:56:38 +01:00
Stuart Cook
ebd5d75dbc
Rollup merge of #150852 - uefi-fs-write, r=joboet
std: sys: fs: uefi: Implement File::write

Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-01-11 14:27:57 +11:00
Stuart Cook
26da51d2a0
Rollup merge of #150804 - std_detect_less_features, r=tgross35
Remove std_detect_file_io and std_detect_dlsym_getauxval features

They were introduced back when std_detect was a standalone crate published to crates.io. The [motivation](https://github.com/rust-lang/stdarch/issues/655) for `std_detect_dlsym_getauxval` was to allow using `getauxval` without `dlopen` when statically linking musl, which we now unconditionally do for musl. And for `std_detect_file_io` to allow `no_std` usage, which std_detect now supports even with that feature enabled as it directly uses libc. This also prevents accidentally disabling runtime feature detection when using `cargo build -Zbuild-std -Zbuild-std-features=`
2026-01-11 14:27:57 +11:00
Stuart Cook
dda4963edb
Rollup merge of #148196 - std-fs-iterative-create-dir-all, r=Mark-Simulacrum,jhpratt
Implement create_dir_all() to operate iteratively instead of recursively

The current implementation of `create_dir_all(...)` in std::fs operates recursively. As mentioned in rust-lang/rust#124309, this could run into a stack overflow with big paths. To avoid this stack overflow issue, this PR implements the method in an iterative manner, preserving the documented behavior of:
```
Recursively create a directory and all of its parent components if they are missing.
This function is not atomic. If it returns an error, any parent components it was able to create will remain.
If the empty path is passed to this function, it always succeeds without creating any directories.
```
2026-01-11 14:27:55 +11:00
Ayush Singh
6878e73d26
std: sys: fs: uefi: Implement File::seek
- Tested using OVMF on QEMU.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-10 22:13:03 +05:30
Ayush Singh
ccc86f2228
std: sys: fs: uefi: Implement File::write
Tested using OVMF on QEMU.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-10 09:24:59 +05:30
Urgau
c2f0209c3c
Rollup merge of #150881 - fix-wasi-fs-copy, r=alexcrichton
Fix std::fs::copy on WASI by setting proper OpenOptions flags

When PR rust-lang/rust#147572 switched WASI to use Unix-style filesystem APIs, the open_to_and_set_permissions function for WASI was implemented to call OpenOptions::new().open() without setting any access mode flags.

This causes std::fs::copy to fail with the error:
"must specify at least one of read, write, or append access"

The fix is to explicitly set .write(true), .create(true), and .truncate(true) on the OpenOptions, matching the behavior of the non-WASI Unix implementation but without the permission handling that WASI doesn't support.

Minimal reproduction:
```rs
    fn main() {
        std::fs::write("/src.txt", b"test").unwrap();
        match std::fs::copy("/src.txt", "/dst.txt") {
            Ok(_) => println!("PASS: fs::copy works!"),
            Err(e) => println!("FAIL: {}", e),
        }
    }
```
    # Compile and run:
    rustc +nightly --target wasm32-wasip2 test.rs -o test.wasm
    wasmtime -S cli --dir . test.wasm

    # Before fix: FAIL: must specify at least one of read, write, or append access
    # After fix:  PASS: fs::copy works!

Note: The existing test library/std/src/fs/tests.rs::copy_file_ok would have caught this regression if the std test suite ran on WASI targets. Currently std tests don't compile for wasm32-wasip2 due to Unix-specific test code in library/std/src/sys/fd/unix/tests.rs.

Fixes the regression introduced in nightly-2025-12-10.

r? @alexcrichton
2026-01-09 23:28:25 +01:00
Urgau
92b9e84172
Rollup merge of #150855 - uefi-fs-tell, r=joboet
std: sys: fs: uefi: Implement File::tell

- Just a call to get_position
- Tested with OVMF on QEMU

@rustbot label +O-UEFI
2026-01-09 23:28:24 +01:00
Urgau
93f6171e11
Rollup merge of #150853 - uefi-fs-read, r=joboet
std: sys: fs: uefi: Implement File::read

Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-01-09 23:28:17 +01:00
Ayush Singh
f6f901fa6d
std: sys: fs: uefi: Implement File::{flush, *sync}
- Make flush a noop since it is only for buffered writers.
- Also forward fsync to datasync. UEFI does not have anything
  separate for metadata sync.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-09 22:36:44 +05:30
Ayush Singh
fd59b32f8b
std: sys: fs: uefi: Implement File::read
Tested using OVMF on QEMU.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-09 22:32:40 +05:30
Colin Murphy
43c1db7d56 Run clippy 2026-01-09 11:51:59 -05:00
Colin Murphy
2cde8d967a Fix std::fs::copy on WASI by setting proper OpenOptions flags
When PR #147572 switched WASI to use Unix-style filesystem APIs, the
open_to_and_set_permissions function for WASI was implemented to call
OpenOptions::new().open() without setting any access mode flags.

This causes std::fs::copy to fail with the error:
"must specify at least one of read, write, or append access"

The fix is to explicitly set .write(true), .create(true), and
.truncate(true) on the OpenOptions, matching the behavior of the
non-WASI Unix implementation but without the permission handling
that WASI doesn't support.

Minimal reproduction:
    fn main() {
        std::fs::write("/src.txt", b"test").unwrap();
        match std::fs::copy("/src.txt", "/dst.txt") {
            Ok(_) => println!("PASS: fs::copy works!"),
            Err(e) => println!("FAIL: {}", e),
        }
    }

    # Compile and run:
    rustc +nightly --target wasm32-wasip2 test.rs -o test.wasm
    wasmtime -S cli --dir . test.wasm

    # Before fix: FAIL: must specify at least one of read, write, or append access
    # After fix:  PASS: fs::copy works!

Note: The existing test library/std/src/fs/tests.rs::copy_file_ok
would have caught this regression if the std test suite ran on WASI
targets. Currently std tests don't compile for wasm32-wasip2 due to
Unix-specific test code in library/std/src/sys/fd/unix/tests.rs.

Fixes the regression introduced in nightly-2025-12-10.
2026-01-09 10:16:00 -05:00
Guillaume Gomez
3daf9935c5
Rollup merge of #150561 - semiopaque, r=BoxyUwU
Finish transition from `semitransparent` to `semiopaque` for `rustc_macro_transparency`

Since it's a bit annoying to have different names for the same thing.

My understanding is that this is just internal stuff that is not part of any public API even tough rust-analyzer knows about it.

Continuation of
- https://github.com/rust-lang/rust/pull/139084.

Discovered while investigating
- https://github.com/rust-lang/rust/issues/150514
2026-01-09 11:59:59 +01:00
Ayush Singh
97fc739602
std: sys: fs: uefi: Implement File::tell
- Just a call to get_position
- Tested with OVMF on QEMU

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-09 10:44:59 +05:30
rust-bors[bot]
3fda0e426c
Auto merge of #150839 - matthiaskrgr:rollup-3a0ebXJ, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#149961 (tidy: add if-installed prefix condition to extra checks system)
 - rust-lang/rust#150475 (std: sys: fs: uefi: Implement initial File)
 - rust-lang/rust#150533 (std: sys: fs: uefi: Implement remove_dir_all)
 - rust-lang/rust#150549 (fix missing_panics_doc in `std::os::fd::owned`)
 - rust-lang/rust#150699 (MGCA: Support literals as direct const arguments)
 - rust-lang/rust#150721 (Deprecated doc intra link)
 - rust-lang/rust#150802 (Minor cleanups to fn_abi_new_uncached)
 - rust-lang/rust#150803 (compiler-builtins subtree update)
 - rust-lang/rust#150809 (Update `literal-escaper` version to `0.0.7`)
 - rust-lang/rust#150811 (Store defids instead of symbol names in the aliases list)
 - rust-lang/rust#150825 (Query associated_item_def_ids when needed)

r? @ghost
2026-01-08 23:40:03 +00:00
Matthias Krüger
e7560df897
Rollup merge of #150549 - patch-1, r=ChrisDenton
fix missing_panics_doc in `std::os::fd::owned`

https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
2026-01-08 22:21:16 +01:00
Matthias Krüger
836ff9c06d
Rollup merge of #150533 - uefi-fs-rmdirall, r=ChrisDenton
std: sys: fs: uefi: Implement remove_dir_all

- Using the implementation from sys::fs::common since UEFI does not have a built-in for this functionality.

@rustbot label +O-UEFI
2026-01-08 22:21:15 +01:00
Matthias Krüger
d21770710b
Rollup merge of #150475 - uefi-fs-file, r=ChrisDenton
std: sys: fs: uefi: Implement initial File

- Implement basic opening and creating files.
- Also implement debug.

@rustbot label +O-UEFI
2026-01-08 22:21:15 +01:00
rust-bors[bot]
31cd367b9c
Auto merge of #148545 - cramertj:alloc-map, r=Amanieu
Add allocator parameter to HashMap

Hashbrown support originally added in https://github.com/rust-lang/hashbrown/pull/133
Part of https://github.com/rust-lang/wg-allocators/issues/7

~See also: hashset support in https://github.com/rust-lang/rust/pull/148550~ (Edit: merged into this PR for crater)
2026-01-08 20:22:35 +00:00
Martin Nordholts
8e3d60447c Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
bjorn3
665770ec84 Remove std_detect_file_io and std_detect_dlsym_getauxval features
They were introduced back when std_detect was a standalone crate
published to crates.io. The motivation for std_detect_dlsym_getauxval
was to allow using getauxval without dlopen when statically linking
musl, which we now unconditionally do for musl. And for
std_detect_file_io to allow no_std usage, which std_detect now supports
even with that feature enabled as it directly uses libc. This also
prevents accidentally disabling runtime feature detection when using
cargo build -Zbuild-std -Zbuild-std-features=
2026-01-08 14:50:12 +00:00
Alan Somers
ebd0151c81 Fix the connect_error test on FreeBSD 15+
On FreeBSD 15, the error code returned in this situation changed.  It's
now ENETUNREACH.  I think that error code is reasonable, and it's
documented for connect(2), so we should expect that it might be
returned.
2026-01-07 10:42:00 -07:00
The 8472
1cd87525e6 Unix implementation for stdio set/take/replace 2026-01-06 16:57:11 +01:00
Jonathan Brouwer
3b0d35f94b
Rollup merge of #150412 - the8472:pidfd-spawn, r=tgross35
use PIDFD_GET_INFO ioctl when available

This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.

Tracking issue: https://github.com/rust-lang/rust/issues/82971
2026-01-06 16:19:41 +01:00
The 8472
fa4a62b066 use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case
where the child is spawned but we can't get the pid.
And `pidfd.{try_}wait` will be able to return the exit status even after a process has been reaped.
At least on newer kernels.
2026-01-06 01:13:09 +01:00
bors
b7bcaa5c71 Auto merge of #143741 - connortsui20:oneshot, r=joboet
`oneshot` Channel

Tracking Issue: https://github.com/rust-lang/rust/issues/143674

This PR adds an experimental `oneshot` module.

Before talking about the API itself, I would prefer to get some of these questions below out of the way first. And as discussed in the [ACP](https://github.com/rust-lang/libs-team/issues/610) it would be

# Unresolved Questions

- [x] ~~Why exactly is it okay for `Sender` to be `Sync`? Or basically, how do we boil down the discussion in https://github.com/rust-lang/rust/pull/111087 into a comment for the `unsafe impl<T: Send> Sync for Sender<T> {}`?~~
- [x] ~~Why is `mpsc::Receiver` `!Sync` but `mpmc::Receiver` is `Sync`? Should `oneshot::Receiver` be `Sync` or not?~~
- [ ] Should this PR try to add an `is_ready` method as proposed in the tracking issue? If so, then the surface of this PR would likely need to increase to add a `pub(crate) fn is_disconnected` method to `mpmc` (might even be a good idea to add that to all 3 channel flavors).
- [ ] In a similar vein to the previous question, should the first internal implementation simply be a wrapper around `mpmc`, or should it be a wrapper around the internal crossbeam implementation?
- [ ] Should the `Sender` and `Receiver` operations be methods or associated methods? So `sender.send(msg)` or `Sender::send(sender, msg)`? The method syntax is more consistent with the rest of the ecosystem (namely `tokio`)
2026-01-05 11:35:43 +00:00
Jacob Pratt
d788ec5e9a
Rollup merge of #150684 - moturus:main, r=jhpratt
Motor OS: fix compile error

PR https://github.com/rust-lang/rust/pull/146341 introduced a compilation error. This fixes it.
2026-01-05 00:16:35 -05:00
Jacob Pratt
a1221deafd
Rollup merge of #150547 - Ayush1325:uefi-rename, r=jhpratt
std: sys: fs: uefi: Implement rename

- Using the file_name field in `EFI_FILE_INFO` works for renaming, even when changing directories.
- Does not work for cross-device rename, but that is already expected behaviour according to the docs:

  "This will not work if the new name is on a different mount point."

- Also add some helper code for dealing with UefiBox<file::Info>.
- Tested using OVMF in qemu.
- edk2 implementation of the same: 66346d5ede/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c (L455)

``@rustbot`` label +O-UEFI
2026-01-05 00:16:34 -05:00
Ayush Singh
3f773fac3b
std: sys: fs: uefi: Implement remove_dir_all
- Using the implementation from sys::fs::common since UEFI does not have
  a built-in for this functionality.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-05 10:31:57 +05:30
U. Lasiotus
3f1dd92cc7 Motor OS: fix compile error
PR https://github.com/rust-lang/rust/pull/146341 introduced
a compilation error. This fixes it.
2026-01-04 16:55:57 -08:00
Connor Tsui
b481ecd8b5
add oneshot tests
Tests inspired by tests in the `oneshot` third-party crate.
2026-01-05 09:47:20 +11:00
Connor Tsui
9ba5b5e7f7
add experimental oneshot channel
The `oneshot` channel is gated under the `oneshot_channel` feature.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2026-01-05 09:47:15 +11:00
bors
5afdf5d8c0 Auto merge of #150669 - Zalathar:rollup-7ar4hqp, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#150201 (compiletest: Support revisions in debuginfo (read: debugger) tests)
 - rust-lang/rust#150642 (mutex.rs: remove needless-maybe-unsized bounds)
 - rust-lang/rust#150643 (vec in-place-drop: avoid creating an intermediate slice)
 - rust-lang/rust#150650 (Forbid generic parameters in types of #[type_const] items)
 - rust-lang/rust#150658 (Clarify panic conditions in `Iterator::last`)
 - rust-lang/rust#150659 (Add missing translator resources for interface parse_cfg and parse_check_cfg)
 - rust-lang/rust#150666 (Fix ambig-unambig-ty-and-consts link)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-04 13:34:53 +00:00
Stuart Cook
0f906208b6
Rollup merge of #150642 - hkBst:needless-maybe-sized-1, r=jhpratt
mutex.rs: remove needless-maybe-unsized bounds

Fixes for:

```text
warning: `?Sized` bound is ignored because of a `Sized` requirement
   --> library/std/src/sync/nonpoison/mutex.rs:425:9
    |
425 | impl<T: ?Sized + Default> Default for Mutex<T> {
    |         ^^^^^^
    |
note: `T` cannot be unsized because of the bound
   --> library/std/src/sync/nonpoison/mutex.rs:425:18
    |
425 | impl<T: ?Sized + Default> Default for Mutex<T> {
    |                  ^^^^^^^
    = note: ...because `Default` has the bound `Sized`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_maybe_sized
    = note: `-W clippy::needless-maybe-sized` implied by `-W clippy::suspicious`
    = help: to override `-W clippy::suspicious` add `#[allow(clippy::needless_maybe_sized)]`
help: change the bounds that require `Sized`, or remove the `?Sized` bound
    |
425 - impl<T: ?Sized + Default> Default for Mutex<T> {
425 + impl<T: Default> Default for Mutex<T> {
    |

warning: `?Sized` bound is ignored because of a `Sized` requirement
   --> library/std/src/sync/poison/mutex.rs:691:9
    |
691 | impl<T: ?Sized + Default> Default for Mutex<T> {
    |         ^^^^^^
    |
note: `T` cannot be unsized because of the bound
   --> library/std/src/sync/poison/mutex.rs:691:18
    |
691 | impl<T: ?Sized + Default> Default for Mutex<T> {
    |                  ^^^^^^^
    = note: ...because `Default` has the bound `Sized`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_maybe_sized
help: change the bounds that require `Sized`, or remove the `?Sized` bound
    |
691 - impl<T: ?Sized + Default> Default for Mutex<T> {
691 + impl<T: Default> Default for Mutex<T> {
```
2026-01-04 21:37:03 +11:00
Jeremy Smart
d236b8a4f1
Add Dir::open(_file) and some trait impls 2026-01-03 18:03:30 -05:00
Matthias Krüger
1fe83d5b91
Rollup merge of #150641 - joboet:netbsd-bindings, r=tgross35
std: remove manual bindings on NetBSD

These have been added to `libc`, so there's no need to redefine them in `std`.
2026-01-03 12:43:37 +01:00
Matthias Krüger
01141eae58
Rollup merge of #145339 - Ayush1325:uefi-tcp4-accept, r=tgross35
std: sys: net: uefi: tcp: Initial TcpListener support

Add support for binding and accepting TCP4 connections.

While testing, the following network options were used with QEMU + OVMF: -nic user,hostfwd=tcp::12345-:12345

The default localhost address on qemu seems to be 10.0.2.15.

UEFI spec does not seem to state that the TCP Handle returned by the Accept method has a ServiceBinding Protocol. So have made the ServiceBinding Protocol optional.

cc `@nicholasbishop`
2026-01-03 12:43:36 +01:00
Marijn Schouten
b2e6e0374d mutex.rs: remove needless-maybe-unsized bounds 2026-01-03 11:17:29 +00:00
joboet
0e5a4fb302
std: remove manual bindings on NetBSD 2026-01-03 11:46:06 +01:00
joboet
7834c43ea6
beautify comment in sys::helpers 2026-01-02 18:32:35 +01:00
joboet
d8489c1ea0
std: remove outdated documentation in sys 2026-01-02 18:23:40 +01:00
joboet
f4fe287d87
std: update imports of sys::helpers 2026-01-02 18:23:40 +01:00
joboet
ae09be5968
std: unify sys::pal::common and sys_common into sys::helpers 2026-01-02 18:23:39 +01:00
Ayush Singh
b725981fe2
std: sys: fs: uefi: Implement rename
- Using the file_name field in `EFI_FILE_INFO` works for renaming, even
  when changing directories.
- Does not work for cross-device rename, but that is already expected
  behaviour according to the docs:

  "This will not work if the new name is on a different mount point."

- Also add some helper code for dealing with UefiBox<file::Info>.
- Tested using OVMF in qemu.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-01 11:53:10 +05:30
Jonathan Brouwer
9b89b8814a
Rollup merge of #149778 - tbu-:pr_crate_io_result, r=Mark-Simulacrum
`crate::io::Result` → `io::Result` in most places

I don't know why many places refer to the type as `crate::io::Result` when `crate::io` is already imported.
2026-01-01 02:47:19 +01:00
bors
8d670b93d4 Auto merge of #150546 - JonathanBrouwer:rollup-jkqji1j, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146798 (RISC-V: Implement (Zkne or Zknd) intrinsics correctly)
 - rust-lang/rust#150337 (docs: fix typo in std::io::buffered)
 - rust-lang/rust#150530 (Remove `feature(string_deref_patterns)`)
 - rust-lang/rust#150543 (`rust-analyzer` subtree update)
 - rust-lang/rust#150544 (Use --print target-libdir in run-make tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-31 18:42:17 +00:00