about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-03-24Rollup merge of #138662 - Ayush1325:uefi-fs-1, r=nicholasbishop,petrochenkovMatthias Krüger-12/+62
Implement some basics in UEFI fs - Just getting some basics out of the way while waiting for #138236 to be merged. - Adds `fs::canonicalize`. Should be same as absolute in case of UEFI since there is no symlink support and absolute path is guaranteed to be uniqe according to spec. - Make `fs::lstat` same as `fs::stat`. Should be same since UEFI does not have symlink support. - Implement `OptionOptions`. cc ````@nicholasbishop```` ````@dvdhrm````
2025-03-24std: fs: uefi: Implement OpenOptionsAyush Singh-8/+58
UEFI does not have specific modes for create_new, truncate and append. So those need to to be simulated after opening the file. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-24std: fs: uefi: Make lstat call statAyush Singh-2/+2
- UEFI does not have symlinks. So lstat and stat should behave the same. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-24std: fs: uefi: Implement canonicalizeAyush Singh-2/+2
- Should be same as absolute in UEFI since there are no symlinks. - Also each absolute path representation should be unique according to the UEFI specification. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-23Trusty: Fix build for anonymous pipes and std::sys::processThalia Archibald-6/+14
PRs #136842 (Add libstd support for Trusty targets), #137793 (Stablize anonymous pipe), and #136929 (std: move process implementations to `sys`) merged around the same time, so update Trusty to take them into account.
2025-03-23Rollup merge of #138671 - ChrisDenton:filetype, r=joshtriplettJacob Pratt-18/+32
Fix `FileType` `PartialEq` implementation on Windows Fixes #138668 On Windows the [`FileType`](https://doc.rust-lang.org/stable/std/fs/struct.FileType.html) struct was deriving `PartialEq` which in turn means it was doing a bit-for-bit comparison on the file attributes and reparse point. This is wrong because `attributes` may contain many things unrelated to file type. `FileType` on Windows allows for four possible combinations (see also [`FileTypeExt`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html)): `file`, `dir`, `symlink_file` and `symlink_dir`. So the new implementation makes sure both symlink and directory information match (and only those things). This could be considered just a bug fix but it is a behaviour change so someone from libs-api might want to FCP this (or might not)...
2025-03-23Rollup merge of #138667 - Ayush1325:uefi-mkdir, r=joboetMichael Goulet-4/+30
std: uefi: fs: Implement mkdir - Since there is no direct mkdir in UEFI, first check if a file/dir with same path exists and then create the directory. cc `@dvdhrm` `@nicholasbishop`
2025-03-23Rollup merge of #138631 - thaliaarchi:sgx-read-buf-test, r=workingjubileeMichael Goulet-6/+2
Update test for SGX now implementing `read_buf` In #108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that #137355 implemented it for SGX types. cc ````@jethrogb````
2025-03-23Rollup merge of #138236 - Ayush1325:uefi-event, r=petrochenkovMichael Goulet-38/+58
uefi: Add OwnedEvent abstraction - Events are going to become quite important for Networking, so needed owned abstractions. - Switch to OwnedEvent abstraction for Exit boot services event. cc ````@nicholasbishop````
2025-03-23Auto merge of #136929 - joboet:move_process_pal, r=Mark-Simulacrumbors-104/+90
std: move process implementations to `sys` As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-23Auto merge of #136769 - thaliaarchi:io-optional-methods/stdio, r=joboetbors-161/+136
Provide optional `Read`/`Write` methods for stdio Override more of the default methods for `io::Read` and `io::Write` for stdio types, when efficient to do so, and deduplicate unsupported types. Tracked in https://github.com/rust-lang/rust/issues/136756. try-job: x86_64-msvc-1
2025-03-22Auto merge of #138841 - matthiaskrgr:rollup-bfkls57, r=matthiaskrgrbors-7/+18
Rollup of 8 pull requests Successful merges: - #138018 (rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.) - #138294 (Mark some std tests as requiring `panic = "unwind"`) - #138468 (rustdoc js: add nonnull helper and typecheck src-script.js) - #138675 (Add release notes for 1.85.1) - #138765 (Fix Thread::set_name on cygwin) - #138786 (Move some driver code around) - #138793 (target spec check: better error when llvm-floatabi is missing) - #138822 (De-Stabilize `file_lock`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-22Auto merge of #138831 - matthiaskrgr:rollup-3t0dqiz, r=matthiaskrgrbors-0/+87
Rollup of 7 pull requests Successful merges: - #138609 (Add stack overflow handler for cygwin) - #138639 (Clean UI tests 2 of n) - #138773 (catch_unwind intrinsic: document return value) - #138782 (test(ui): add tuple-struct-where-clause-suggestion ui test for #91520) - #138794 (expand: Do not report `cfg_attr` traces on macros as unused attributes) - #138801 (triagebot: add autolabel rules for D-* and L-*) - #138804 (Allow inlining for `Atomic*::from_ptr`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-22Rollup merge of #138822 - moxian:unlock, r=joshtriplettMatthias Krüger-5/+10
De-Stabilize `file_lock` This reverts #136794 FCP on the tracking issue (#130994) passsed successfully https://github.com/rust-lang/rust/issues/130994#issuecomment-2646158607 but there are now concerns about the suitability of the proposed API (https://github.com/rust-lang/rust/issues/130994#issuecomment-2734608366) On zullip it was [suggested](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/File.3A.3Atry_lock.20API.3A.20Result.3Cbool.3E/near/506823067) that it would be better to temporarily(?) destabilize the feature ASAP to buy us some more time reflecting on the API. This PR implements the revert. The feature is not currently on beta (https://github.com/rust-lang/rust/blob/beta/library/std/src/fs.rs#L672) so a beta backport is not yet neccessary. If this revert is accepted, the tracking issue (#130994) should be reopened
2025-03-22Rollup merge of #138765 - Berrysoft:cygwin-thread-name, r=joboetMatthias Krüger-2/+3
Fix Thread::set_name on cygwin Just like Linux, Cygwin also sets a limitation to thread name. https://github.com/cygwin/cygwin/blob/8e50c7af7c49819245739d6f626f6fecc394ef7f/winsup/cygwin/thread.cc#L3175
2025-03-22Rollup merge of #138294 - paulmenage:test-panic-unwind, r=bjorn3Matthias Krüger-0/+5
Mark some std tests as requiring `panic = "unwind"` This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
2025-03-22std: move process implementations to `sys`joboet-104/+90
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-22Rollup merge of #138609 - Berrysoft:cygwin-stackoverflow, r=joboetMatthias Krüger-0/+87
Add stack overflow handler for cygwin The cygwin runtime handles stack overflow exception and converts it to `SIGSEGV`, but the passed `si_addr` is obtained from `ExceptionInformation[1]` which is actually an undocumented value when stack overflows. Thus I choose to use Windows API directly to register handler, just like how std does on native Windows. The code is basically copied from the Windows one. Ref: * https://github.com/cygwin/cygwin/blob/5ec497dc80bcb7ad78cc07bb919b2624b361f017/winsup/cygwin/exceptions.cc#L822-L823 * https://learn.microsoft.com/zh-cn/windows/win32/api/winnt/ns-winnt-exception_record
2025-03-22Rollup merge of #138673 - taiki-e:trusty-fix, r=NoratriebMatthias Krüger-1/+1
Fix build failure on Trusty This target is currently broken due to update to 2024 editon. ```console $ cargo new --lib repro $ cd repro $ cargo check -Z build-std=std --target aarch64-unknown-trusty Compiling std v0.0.0 ($HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std) error: extern blocks must be unsafe --> $HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/random/trusty.rs:1:1 | 1 | / extern "C" { 2 | | fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); 3 | | } | |_^ error: could not compile `std` (lib) due to 1 previous error ``` cc ```@randomPoison``` ```@ahomescu``` ([target maintainers](https://doc.rust-lang.org/nightly/rustc/platform-support/trusty.html#target-maintainers))
2025-03-22Rollup merge of #138490 - tbu-:pr_arc_file_pos, r=NoratriebMatthias Krüger-0/+3
Forward `stream_position` in `Arc<File>` as well It was missed in #137165.
2025-03-22Use unit structs for stateless stdioThalia Archibald-12/+12
This seems to be the pattern for newer pal stdio types.
2025-03-22Implement exact reads for StdinRawThalia Archibald-28/+35
2025-03-22Implement optional methods for unsupported stdioThalia Archibald-1/+64
Match what `std::io::Empty` does, since it is very similar. However, still evaluate the `fmt::Arguments` in `write_fmt` to be consistent with other platforms.
2025-03-22Implement `UniqueArc`Frank King-0/+2
2025-03-21Revert "Stabilize file_lock"moxian-5/+10
This reverts commit 82af73dd4c58cd6bec5fb44cf02f7ac96b1ed48b.
2025-03-21Rollup merge of #138650 - thaliaarchi:io-write-fmt-known, r=ibraheemdevMatthias Krüger-35/+46
Optimize `io::Write::write_fmt` for constant strings When the formatting args to `fmt::Write::write_fmt` are a statically known string, it simplifies to only calling `write_str` without a runtime branch. Do the same in `io::Write::write_fmt` with `write_all`. Also, match the convention of `fmt::Write` for the name of `args`.
2025-03-21Rollup merge of #137357 - syvb:sv/log-docs, r=tgross35Matthias Krüger-0/+200
Document results of non-positive logarithms The integer versions of logarithm functions panic on non-positive numbers. The floating point versions have different, undocumented behaviour (-inf on 0, NaN on <0). This PR documents that. try-job: aarch64-gnu
2025-03-21Fix Thread::set_name on cygwin王宇逸-2/+3
2025-03-20wasm: increase default thread stack size to 1 MBSebastian Urban-2/+2
The default stack size for the main thread is 1 MB as specified by linker options. However, the default stack size for threads was only 64 kB. This is surprisingly small and thus we increase it to 1 MB to match the main thread.
2025-03-19Document results of non-positive logarithmssyvb-0/+200
2025-03-19Rollup merge of #137051 - thaliaarchi:io-optional-impls/empty, r=m-ou-seMatthias Krüger-11/+216
Implement default methods for `io::Empty` and `io::Sink` Implements default methods of `io::Read`, `io::BufRead`, and `io::Write` for `io::Empty` and `io::Sink`. These implementations are equivalent to the defaults, except in doing less unnecessary work. `Read::read_to_string` and `BufRead::read_line` both have a redundant call to `str::from_utf8` which can't be inlined from `core` and `Write::write_all_vectored` has slicing logic which can't be simplified (See on [Compiler Explorer](https://rust.godbolt.org/z/KK6xcrWr4)). The rest are optimized to the minimal with `-C opt-level=3`, but this PR gives that benefit to unoptimized builds. This includes an implementation of `Write::write_fmt` which just ignores the `fmt::Arguments<'_>`. This could be problematic whenever a user formatting impl is impure, but the docs do not guarantee that the args will be expanded. Tracked in https://github.com/rust-lang/rust/issues/136756. r? `@m-ou-se`
2025-03-19Rollup merge of #135394 - clarfonthey:uninit-slices-part-2, r=tgross35Matthias Krüger-2/+1
`MaybeUninit` inherent slice methods part 2 These were moved out of #129259 since they require additional libs-api approval. Tracking issue: #117428. New API surface: ```rust impl<T> [MaybeUninit<T>] { // replacing fill; renamed to avoid conflict pub fn write_filled(&mut self, value: T) -> &mut [T] where T: Clone; // replacing fill_with; renamed to avoid conflict pub fn write_with<F>(&mut self, value: F) -> &mut [T] where F: FnMut() -> T; // renamed to remove "fill" terminology, since this is closer to the write_*_of_slice methods pub fn write_iter<I>(&mut self, iter: I) -> (&mut [T], &mut Self) where I: Iterator<Item = T>; } ``` Relevant motivation for these methods; see #129259 for earlier methods' motiviations. * I chose `write_filled` since `filled` is being used as an object here, whereas it's being used as an action in `fill`. * I chose `write_with` instead of `write_filled_with` since it's shorter and still matches well. * I chose `write_iter` because it feels completely different from the fill methods, and still has the intent clear. In all of the methods, it felt appropriate to ensure that they contained `write` to clarify that they are effectively just special ways of doing `MaybeUninit::write` for each element of a slice. Tracking issue: https://github.com/rust-lang/rust/issues/117428 r? libs-api
2025-03-19Auto merge of #138693 - matthiaskrgr:rollup-ejq8mwp, r=matthiaskrgrbors-24/+17
Rollup of 10 pull requests Successful merges: - #136177 (clarify BufRead::{fill_buf, consume} docs) - #138654 (Remove the regex dependency from coretests) - #138655 (rustc-dev-guide sync) - #138656 (Remove double nesting in post-merge workflow) - #138658 (CI: mirror alpine and centos images to ghcr) - #138659 (coverage: Don't store a body span in `FunctionCoverageInfo`) - #138661 (Revert: Add *_value methods to proc_macro lib) - #138670 (Remove existing AFIDT implementation) - #138674 (Various codegen_llvm cleanups) - #138684 (use then in docs for `fuse` to enhance readability) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-19Allow spawning threads after TLS destruction.Mara Bos-9/+14
2025-03-19Auto merge of #138653 - matthiaskrgr:rollup-fwwqmr7, r=matthiaskrgrbors-10/+49
Rollup of 7 pull requests Successful merges: - #136320 (exit: document interaction with C) - #138080 (Leave a breadcrumb towards bootstrap config documentation in `bootstrap.toml`) - #138301 (Implement `read_buf` for Hermit) - #138569 (rustdoc-json: Add tests for `#[repr(...)]`) - #138635 (Extract `for_each_immediate_subpat` from THIR pattern visitors) - #138642 (Unvacation myself) - #138644 (Add `#[cfg(test)]` for Transition in dfa in `rustc_transmute`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-19Rollup merge of #136177 - hkBst:patch-24, r=ibraheemdevMatthias Krüger-24/+17
clarify BufRead::{fill_buf, consume} docs Fixes #85394
2025-03-18fix pthread-based tls on apple targetsAndrei Damian-0/+1
2025-03-18Windows: fix FileType PartialEq implementationChris Denton-18/+15
2025-03-19Fix build failure on TrustyTaiki Endo-1/+1
2025-03-18Test windows file type equalityChris Denton-0/+17
2025-03-18Add stack overflow handler for cygwinBerrysoft-0/+87
2025-03-18std: uefi: fs: Implement mkdirAyush Singh-4/+30
- Since there is no direct mkdir in UEFI, first check if a file/dir with same path exists and then create the directory. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-18Apply suggestions from code reviewMarijn Schouten-7/+7
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-03-18Rollup merge of #138301 - thaliaarchi:io-optional-methods/hermit, r=tgross35Matthias Krüger-6/+18
Implement `read_buf` for Hermit Following https://github.com/hermit-os/kernel/pull/1606, it is now safe to implement `Read::read_buf` for file descriptors on Hermit. cc ```@mkroening```
2025-03-18Rollup merge of #136320 - RalfJung:exit, r=the8472Matthias Krüger-4/+31
exit: document interaction with C Cc https://github.com/rust-lang/rust/issues/126600
2025-03-18Auto merge of #135368 - Ayush1325:uefi-fs-2, r=jhpratt,nicholasbishopbors-5/+138
uefi: fs: Implement exists Also adds the initial file abstractions. The file opening algorithm is inspired from UEFI shell. It starts by classifying if the Path is Shell mapping, text representation of device path protocol, or a relative path and converts into an absolute text representation of device path protocol. After that, it queries all handles supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the device path protocol prefix (similar to Windows drive). After that, it opens the file in the volume using the remaining pat. It also introduces OwnedDevicePath and BorrowedDevicePath abstractions to allow working with the base UEFI and Shell device paths efficiently. DevicePath in UEFI behaves like an a group of nodes laied out in the memory contiguously and thus can be modeled using iterators. This is an effort to break the original PR (https://github.com/rust-lang/rust/pull/129700) into much smaller chunks for faster upstreaming.
2025-03-18Optimize io::Write::write_fmt for constant stringsThalia Archibald-35/+46
When the formatting args to `fmt::Write::write_fmt` are a statically known string, it simplifies to only calling `write_str` without a runtime branch. Do the same in `io::Write::write_fmt` with `write_all`. Also, match the convention of `fmt::Write` for the name of `args`.
2025-03-18uefi: fs: Implement existsAyush Singh-5/+138
Also adds the initial file abstractions. The file opening algorithm is inspired from UEFI shell. It starts by classifying if the Path is Shell mapping, text representation of device path protocol, or a relative path and converts into an absolute text representation of device path protocol. After that, it queries all handles supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the device path protocol prefix (similar to Windows drive). After that, it opens the file in the volume using the remaining pat. It also introduces OwnedDevicePath and BorrowedDevicePath abstractions to allow working with the base UEFI and Shell device paths efficiently. DevicePath in UEFI behaves like an a group of nodes laied out in the memory contiguously and thus can be modeled using iterators. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-17Update test for SGX now implementing read_bufThalia Archibald-6/+2
In #108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that #137355 implemented it for SGX types.
2025-03-17Implement read_buf for HermitThalia Archibald-6/+18