about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-05-18Rollup merge of #140966 - est31:let_chains_library, r=tgross35León Orell Valerian Liehr-1/+0
Remove #![feature(let_chains)] from library and src/librustdoc PR https://github.com/rust-lang/rust/pull/132833 has stabilized the `let_chains` feature. This PR removes the last occurences from the library, the compiler, and librustdoc (also because #140887 missed the conditional in one of the crates as it was behind the "rustc" feature). We keep `core` as exercise for the future as updating it is non-trivial (see PR thread).
2025-05-17Auto merge of #138087 - tgross35:core-float-math, r=Amanieubors-867/+29
Initial implementation of `core_float_math` Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1], with the exception of `powi` that has been there longer. Details for each of the changes is in the commit messages. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763 try-job: aarch64-gnu tru-job: armhf-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2025-05-17Rollup merge of #139103 - joboet:abort_dedup, r=tgross35Matthias Krüger-30/+25
deduplicate abort implementations Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-16Remove #![feature(let_chains)] from library and src/librustdocest31-1/+0
2025-05-16Rollup merge of #141013 - federico-terzi:feat/command_startupinfo_windows, ↵Matthias Krüger-0/+72
r=joboet Implement methods to set STARTUPINFO flags for Command API on Windows Implements https://github.com/rust-lang/rust/issues/141010
2025-05-16Rollup merge of #140984 - mlowicki:patch-2, r=ibraheemdevMatthias Krüger-2/+2
fix doc for UnixStream Doc example was using `UdpSocket` instead of `UnixStream`.
2025-05-16Rollup merge of #140910 - paolobarbolini:wasi-fs-incorrect-stabilization, ↵Matthias Krüger-2/+0
r=joboet Remove `stable` attribute from wasi fs (read_exact|write_all)_at The docs for [`std::os::wasi::fs::FileExt::read_exact_at`](https://doc.rust-lang.org/1.86.0/std/os/wasi/fs/trait.FileExt.html#method.read_exact_at) and [`std::os::wasi::fs::FileExt::write_all_at`](https://doc.rust-lang.org/1.86.0/std/os/wasi/fs/trait.FileExt.html#method.write_all_at) show the methods to be stable since v1.33, which is not correct and was a mistake made when the methods were added in (https://github.com/rust-lang/rust/pull/74076#pullrequestreview-443124667). The reviewer seemed to think this was an insta-stabilization, but the entire file is marked as unstable so that was not right. The stabilization version would also have been wrong either way.
2025-05-15improve internal fastfail explainerjoboet-3/+2
2025-05-15deduplicate abort implementationsjoboet-30/+26
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-14wire up startupinfo methodsFederico Terzi-0/+72
2025-05-14Fix settimes for vxworksB I Mohammed Abbas-2/+1
2025-05-14Fix set_name for vxworks. Length of name should be truncated to ↵B I Mohammed Abbas-10/+2
VX_TASK_RENAME_LENGTH-1
2025-05-13fix doc for UnixStreamMichał Łowicki-2/+2
2025-05-13Initial implementation of `core_float_math`Trevor Gross-867/+29
Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1]. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763
2025-05-12update cfg(bootstrap)Pietro Albini-274/+182
2025-05-12update version placeholdersPietro Albini-11/+11
2025-05-10Remove `stable` attribute from wasi fs (read_exact|write_all)_atPaolo Barbolini-2/+0
2025-05-10Rollup merge of #140783 - veluca93:oncelock-docs, r=jhprattMatthias Krüger-1/+1
Update documentation of OnceLock::get_or_init. Explicitly point out that if the function panics the init function might be called multiple times.
2025-05-10Rollup merge of #129334 - ChayimFriedman2:more-lazy-methods, r=AmanieuMatthias Krüger-1/+9
Implement (part of) ACP 429: add `DerefMut` to `Lazy[Cell/Lock]` `DerefMut` is instantly stable, as a trait impl. That means this needs an FCP. ``@rustbot`` label +needs-fcp https://github.com/rust-lang/libs-team/issues/429
2025-05-08Rollup merge of #140759 - dpaoliello:symlink, r=workingjubileeMatthias Krüger-0/+16
[win][arm64] Disable std::fs tests that require symlinks While trying to get the aarch64-msvc build working correctly (#140136), various tests in `std::fs` were failing as the Arm64 Windows runner image we are using does not have Developer Mode enabled, thus it cannot create symlinks. I've [filed a request to get Developer Mode enabled](https://github.com/actions/partner-runner-images/issues/94), but in the meantime I've disabled the relevant tests on Arm64 Windows.
2025-05-08Update documentation of OnceLock::get_or_init.Luca Versari-1/+1
Explicitly point out that if the function panics the init function might be called multiple times.
2025-05-07[win][arm64] Disable FS tests that require symlinksDaniel Paoliello-0/+16
2025-05-07Fix regression from #140393 for espidf / horizon / nuttx / vitaivmarkov-0/+1
2025-05-07Rollup merge of #140656 - joboet:fuchsia_pal, r=workingjubileeJacob Pratt-282/+122
collect all Fuchsia bindings into the `fuchsia` module The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally: * deduplicates the definitions * makes the error names consistent * marks `zx_thread_self` and `zx_clock_get_monotonic` as safe extern functions * removes unused items (there's no need to maintain these bindings if we're not going to use them) * removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden) `@rustbot` ping fuchsia
2025-05-06Rollup merge of #140393 - joboet:sys_common_process, r=thomccStuart Cook-136/+176
std: get rid of `sys_common::process` Move the public `CommandEnvs` into the `process` module (and make it a wrapper type for an internal iterator type) and everything else into `sys::process` as per #117276. Something went wrong with a force push, so I can't reopen #139020. This is unchanged from that PR, apart from a rebase. r? ```@thomcc```
2025-05-06Rollup merge of #139773 - thaliaarchi:vec-into-iter-last, r=workingjubileeStuart Cook-2/+2
Implement `Iterator::last` for `vec::IntoIter` Avoid iterating everything when we have random access to the last element.
2025-05-05Consistent trait bounds for ExtractIf Debug implsDavid Tolnay-22/+17
2025-05-05collect all Fuchsia bindings into the `fuchsia` modulejoboet-282/+122
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally: * deduplicates the definitions * makes the error names consistent * marks some extern functions as safe * removes unused items (there's no need to maintain these bindings if we're not going to use them) * removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
2025-05-03Rollup merge of #140595 - lolbinarycat:std-set_permissions-typo, r=cuviperMatthias Krüger-1/+1
doc(std): fix typo lchown -> lchmod chown is irrelevant here, as this function does not affect file ownership. chmod is the correct function to reference here.
2025-05-03Rollup merge of #140564 - ↵Matthias Krüger-3/+3
ebkalderon:use-present-indicative-in-std-io-pipe-docs, r=tgross35 Use present indicative tense in std::io::pipe() API docs The inline documentation for all other free functions in the `std::io` module use the phrase "creates a" instead of "create a", except for the currently nightly-only `std::io::pipe()` function. This commit updates the text to align with the predominant wording in the `std::io` module. I recognize this PR is quite a minuscule nitpick, so feel free to ignore and close if you disagree and/or there are bigger fish to fry. Thanks in advance! :smile: Relates to https://github.com/rust-lang/rust/issues/127154.
2025-05-03Rollup merge of #139343 - cberner:filelock_wouldblock, r=workingjubileeMatthias Krüger-62/+144
Change signature of File::try_lock and File::try_lock_shared These methods now return Result<(), TryLockError> instead of Result<bool, Error> to make their use less errorprone These methods are unstable under the "file_lock" feature. The related tracking issue is https://github.com/rust-lang/rust/pull/130999 and this PR changes the signatures as discussed by libs-api: https://github.com/rust-lang/rust/issues/130994#issuecomment-2770838848
2025-05-02Implement Iterator::last for vec::IntoIterThalia Archibald-2/+2
2025-05-02Rollup merge of #140536 - zachs18:mapped-guard-filter-map, r=AmanieuMatthias Krüger-41/+35
Rename `*Guard::try_map` to `filter_map`. Rename `std::sync::*Guard::try_map` to `filter_map`. 1. Analogous to `std::cell::Ref(Mut)::filter_map`. 2. Doesn't imply `Try` genericizability. r? `@Amanieu` (or other T-libs-api) Tracking issue for `mapped_lock_guards`: https://github.com/rust-lang/rust/issues/117108
2025-05-02doc(std): fix typo lchown -> lchmodbinarycat-1/+1
2025-05-02Rollup merge of #140197 - ktnlvr:master, r=workingjubileeStuart Cook-1/+28
Document breaking out of a named code block Closes #110758.
2025-05-02Rollup merge of #140159 - thaliaarchi:pathbuf-extension, r=workingjubileeStuart Cook-31/+65
Avoid redundant WTF-8 checks in `PathBuf` Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings. To assist in this, mark the internal methods `OsString::truncate` and `extend_from_slice` as `unsafe` to communicate their safety invariants better than with module privacy. Similar to #137777. cc `@joboet` `@ChrisDenton`
2025-05-02Rollup merge of #139847 - thaliaarchi:args/delegate-iter, r=workingjubileeStuart Cook-21/+207
Delegate to inner `vec::IntoIter` from `env::ArgsOs` Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides. `std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type. Add `#[inline]` for any methods which simply wrap the inner iterator.
2025-05-02Rollup merge of #139608 - Lynnesbian:improve-async-block-docs, r=ibraheemdevStuart Cook-0/+60
Clarify `async` block behaviour Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) #101444. r? rust-lang/docs
2025-05-02Rollup merge of #139206 - joboet:unique_thread_errno, r=ibraheemdevStuart Cook-24/+21
std: use the address of `errno` to identify threads in `unique_thread_exit` Getting the address of `errno` should be just as cheap as `pthread_self()` and avoids having to use the expensive `Mutex` logic because it always results in a pointer.
2025-05-01Implement error::Error for TryLockErrorChristopher Berner-1/+4
2025-05-01Change signature of File::try_lock and File::try_lock_sharedChristopher Berner-61/+140
These methods now return Result<(), TryLockError> instead of Result<bool, Error> to make their use less errorprone
2025-05-02Amend language regarding the never typeLynnesbian-2/+2
2025-05-01Delegate to inner `vec::IntoIter` from `env::ArgsOs`Thalia Archibald-21/+207
Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides. `std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type. Add `#[inline]` for any methods which simply wrap the inner iterator.
2025-05-01Rollup merge of #140062 - xizheyin:issue-139958, r=workingjubileeGuillaume Gomez-0/+2
std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concurrently written into Closes #139958 The current documentation for `std::fs::remove_dir_all` function does not explicitly mention the error types that may be returned in concurrent scenarios. Specifically, when one thread attempts to remove a directory tree while another thread simultaneously writes files to that directory, the function may return an `io::ErrorKind::DirectoryNotEmpty` error, but this behavior is not clearly mentioned in the current documentation. r? libs
2025-05-01Use present indicative tense in std::io::pipe() API docsEyal Kalderon-3/+3
The inline documentation for all other free functions in the `std::io` module use the phrase "creates a" instead of "create a", except for the currently nightly-only `std::io::pipe()` function. This commit updates the text to align with the predominant wording in the `std::io` module. I recognize this PR is quite a minuscule nitpick, so feel free to ignore and close if you disagree and/or there are bigger fish to fry. :smile:
2025-05-01Simplify docs for breaking out of a named code blockArtur Roos-2/+2
2025-04-30Avoid redundant WTF-8 checks in `PathBuf`Thalia Archibald-6/+10
Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings.
2025-04-30Make internal `OsString::truncate` and `extend_from_slice` unsafeThalia Archibald-25/+55
Communicate the safety invariants of these methods with `unsafe fn` rather than privacy.
2025-04-30Rename `(Mapped)(RwLock|Mutex)Guard::try_map` to `filter_map`.Zachary S-41/+35
1. analogous to std::cell::Ref(Mut)::filter_map. 2. doesn't imply `Try` genericizability.
2025-04-28Rollup merge of #140323 - tgross35:cfg-unstable-float, r=UrgauChris Denton-90/+450
Implement the internal feature `cfg_target_has_reliable_f16_f128` Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable. Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates: * `cfg(target_has_reliable_f16)` * `cfg(target_has_reliable_f16_math)` * `cfg(target_has_reliable_f128)` * `cfg(target_has_reliable_f128_math)` `reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs. These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up. The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend. MCP: https://github.com/rust-lang/compiler-team/issues/866 Closes: https://github.com/rust-lang/compiler-team/issues/866 [1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186 --- The second commit makes use of this config to replace `cfg_{f16,f128}{,_math}` in `library/`. I omitted providing a `cfg(bootstrap)` configuration to keep things simpler since the next beta branch is in two weeks. try-job: aarch64-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-ext2