about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2025-05-04Update `compiler-builtins` to 0.1.157Trevor Gross-1/+1
Includes the following changes: * Use runtime feature detection for fma routines on x86 [1] Fixes: https://github.com/rust-lang/rust/issues/140452 [1]: https://github.com/rust-lang/compiler-builtins/pull/896
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-02zkVM: Cache args from hostThalia Archibald-55/+31
Retrieve argc/argv from the host once, on demand when the first `env::ArgsOs` is constructed, and globally cache it. Copy each argument to an `OsString` while iterating.
2025-05-02zkVM: Fix env::ArgsOsThalia Archibald-17/+54
The zkVM implementation of `env::ArgsOs` incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in #139847.
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-59/+61
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 #140389 - sayantn:avx512fp16, r=AmanieuStuart Cook-1/+0
Remove `avx512dq` and `avx512vl` implication for `avx512fp16` According to Intel, `avx512fp16` requires only `avx512bw`, but LLVM also enables `avx512vl` and `avx512dq` when `avx512fp16` is active. This is relic code, and will be fixed in LLVM soon. We should remove this from Rust too asap, especially before the stabilization of AVX512 Related: - llvm/llvm-project#136209 - #138940 - rust-lang/stdarch#1781 - #111137 ``@rustbot`` label O-x86_64 O-x86_32 A-SIMD A-target-feature T-compiler -T-libs r? ``@Amanieu`` **Update: the LLVM fix has been merged** cc ``@rust-lang/wg-llvm`` will it be possible to update the rustc llvm version to something after llvm/llvm-project#137450
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-05-01Update stdarchsayantn-1/+0
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-59/+61
1. analogous to std::cell::Ref(Mut)::filter_map. 2. doesn't imply `Try` genericizability.
2025-04-28Reexport types from `c_size_t` in `std`Trevor Gross-0/+2
These are unstably available in `core` and should be in `std` too, but are not currently reexported. Resolve this here.
2025-04-28Rollup merge of #140323 - tgross35:cfg-unstable-float, r=UrgauChris Denton-262/+648
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
2025-04-28std: get rid of `sys_common::process`joboet-136/+176
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.
2025-04-28Auto merge of #123239 - Urgau:dangerous_implicit_autorefs, ↵bors-1/+1
r=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](https://github.com/rust-lang/rust/pull/123239#issuecomment-2727551097)* This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on #103735 with suggestion and improvements from https://github.com/rust-lang/rust/pull/103735#issuecomment-1370420305. The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since #103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
2025-04-28Auto merge of #136316 - GrigorenkoPV:generic_atomic, r=Mark-Simulacrumbors-260/+270
Create `Atomic<T>` type alias (rebase) Rebase of #130543. Additional changes: - Switch from `allow` to `expect` for `private_bounds` on `AtomicPrimitive` - Unhide `AtomicPrimitive::AtomicInner` from docs, because rustdoc shows the definition `pub type Atomic<T> = <T as AtomicPrimitive>::AtomicInner;` and generated links for it. - `NonZero` did not have this issue, because they kept the new alias private before the direction was changed. - Use `Atomic<_>` in more places, including inside `Once`'s `Futex`. This is possible thanks to https://github.com/rust-lang/rust-clippy/pull/14125 The rest will either get moved back to #130543 or #130543 will be closed in favor of this instead. --- * ACP: https://github.com/rust-lang/libs-team/issues/443#event-14293381061 * Tracking issue: #130539
2025-04-28Rollup merge of #140351 - rust-lang:notriddle/stability-use, r=thomccChris Denton-2/+8
docs: fix incorrect stability markers on `std::{todo, matches}` This regression appeared in 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b. The change is behaving as expected (a non-glob re-export uses the stability marker on the `use` item, not the original one), but this part of the standard library didn't follow it. Fixes https://github.com/rust-lang/rust/issues/140344
2025-04-28Rollup merge of #139546 - lolbinarycat:std-set_permissions-75942, r=thomccChris Denton-0/+15
std(docs): clarify how std::fs::set_permisions works with symlinks fixes https://github.com/rust-lang/rust/issues/75942 fixes https://github.com/rust-lang/rust/issues/124201
2025-04-28Rollup merge of #138737 - Ayush1325:r-efi-update, r=tgross35Chris Denton-2/+2
uefi: Update r-efi - Bump up the version to 5.2.0 try-job: x86_64-gnu-distcheck try-job: x86_64-gnu try-job: test-various
2025-04-27Use `feature(target_has_reliable_f16_f128)` in library testsTrevor Gross-262/+648
New compiler configuration has been introduced that is designed to replace the build script configuration `reliable_f16`, `reliable_f128`, `reliable_f16_math`, and `reliable_f128_math`. Do this replacement here, which allows us to clean up `std`'s build script. All tests are gated by `#[cfg(bootstrap)]` rather than doing a more complicated `cfg(bootstrap)` / `cfg(not(bootstrap))` split since the next beta split is within two weeks.
2025-04-27Fix SGX library code implicit auto-refUrgau-1/+1
2025-04-27Rollup merge of #137439 - clarfonthey:c-str-module, r=tgross35Matthias Krüger-2/+1
Stabilise `std::ffi::c_str` This finished FCP in #112134 but never actually got a stabilisation PR. Since the FCP in #120048 recently passed to add the `os_str` module, it would be nice to also merge this too, to ensure that both get added in the next version. Note: The added stability attributes which *somehow* were able to be omitted before (rustc bug?) were added based on the fact that they were added in 302551388b1942bb4216bb5a15d9d55cee3643a8, which ended up in 1.85.0. Closes: https://github.com/rust-lang/rust/issues/112134 r? libs-api
2025-04-27use generic Atomic type where possibleChristopher Durham-260/+270
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-26docs: fix incorrect stability markers on `std::{todo, matches}`Michael Howell-2/+8
This regression appeared in 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b. The change is behaving as expected (a non-glob re-export uses the stability marker on the `use` item, not the original one), but this part of the standard library didn't follow it.
2025-04-26Rollup merge of #140325 - ↵Matthias Krüger-2/+2
ethanwu10:ethanwu10/grammar-fixes-for-bufread-has-data-left-docs, r=jhpratt Grammar fixes for BufRead::has_data_left docs Fix some grammar in the documentation for `BufRead::has_data_left`
2025-04-26uefi: Update r-efiAyush Singh-2/+2
- Bump up the version to 5.2.0 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-25Grammar fixes for BufRead::has_data_left docsEthan Wu-2/+2
2025-04-26Rollup merge of #140216 - t5kd:master, r=tgross35Matthias Krüger-2/+6
Document that "extern blocks must be unsafe" in Rust 2024 The [documentation on `extern`](https://doc.rust-lang.org/std/keyword.extern.html) contains the following code sample: ```rust #[link(name = "my_c_library")] extern "C" { fn my_c_function(x: i32) -> bool; } ``` Due to #123743, attempting to compile such code with the 2024 edition of Rust fails: ``` error: extern blocks must be unsafe ``` This PR extends the `extern` documentation with a brief explanation of the new requirement. It also adds the missing `unsafe` keyword to the code sample, which should be compatible with rustc since v1.82. **Related docs:** - https://doc.rust-lang.org/reference/items/external-blocks.html - https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html
2025-04-25Update `extern` docs for Rust 2024 and add safety remarksTobias-2/+6
2025-04-25Auto merge of #140298 - matthiaskrgr:rollup-5tc1gvb, r=matthiaskrgrbors-1/+8
Rollup of 8 pull requests Successful merges: - #137683 (Add a tidy check for GCC submodule version) - #138968 (Update the index of Result to make the summary more comprehensive) - #139572 (docs(std): mention const blocks in const keyword doc page) - #140152 (Unify the format of rustc cli flags) - #140193 (fix ICE in `#[naked]` attribute validation) - #140205 (Tidying up UI tests [2/N]) - #140284 (remove expect() in `unnecessary_transmutes`) - #140290 (rustdoc: fix typo change from equivelent to equivalent) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Rollup merge of #139572 - ↵Matthias Krüger-1/+8
ismailarilik:docs/std/mention-const-blocks-in-const-keyword-doc-page, r=tgross35 docs(std): mention const blocks in const keyword doc page Aims to close #139549
2025-04-25Auto merge of #140282 - matthiaskrgr:rollup-g6ze4jj, r=matthiaskrgrbors-1218/+964
Rollup of 8 pull requests Successful merges: - #137653 (Deprecate the unstable `concat_idents!`) - #138957 (Update the index of Option to make the summary more comprehensive) - #140006 (ensure compiler existance of tools on the dist step) - #140143 (Move `sys::pal::os::Env` into `sys::env`) - #140202 (Make #![feature(let_chains)] bootstrap conditional in compiler/) - #140236 (norm nested aliases before evaluating the parent goal) - #140257 (Some drive-by housecleaning in `rustc_borrowck`) - #140278 (Don't use item name to look up associated item from trait item) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25Auto merge of #140273 - matthiaskrgr:rollup-rxmuvkg, r=matthiaskrgrbors-1/+4
Rollup of 8 pull requests Successful merges: - #137096 (Stabilize flags for doctest cross compilation) - #140148 (CI: use aws codebuild for job dist-arm-linux) - #140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test) - #140196 (Improved diagnostics for non-primitive cast on non-primitive types (`Arc`, `Option`)) - #140210 (Work around cygwin issue on condvar timeout) - #140213 (mention about `x.py setup` in `INSTALL.md`) - #140229 (`DelimArgs` tweaks) - #140248 (Fix impl block items indent) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-25docs(std): mention const blocks in const keyword doc pageismailarilik-1/+8
2025-04-25Rollup merge of #140143 - thaliaarchi:move-env-pal, r=joboetMatthias Krüger-1218/+962
Move `sys::pal::os::Env` into `sys::env` Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`. Also fix `unsafe_op_in_unsafe_fn` for Unix and update the `!DynSend` and `!DynSync` impls which had grown out of sync with the platforms (see #48005 for discussion on that). r? joboet Tracked in #117276.