about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2025-05-17remove extra tests that really might not be all that usefulGrantBirki-55/+0
2025-05-17revert forward slash to backslashGrantBirki-1/+1
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-17Switch library rustc_unimplemented to use `Self` and `This`mejrs-1/+1
2025-05-16remove `test_embedded_null_byte()` test for nowGrantBirki-20/+0
2025-05-16discuss deadlocks in the std::io::pipe() exampleJack O'Connor-12/+26
2025-05-17Docs(lib/coll/hm): Add kv pair to `extract_if`'s first sentencePaul Mabileau-1/+1
Make it consistent in this regard with `BTreeMap`'s. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/extract_if): Unify paragraph about elements mutationPaul Mabileau-2/+2
Take the one from `BTreeMap` that seems the best-worded and most precise among the available variations. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/extract_if): Unify paragraph about closure actionsPaul Mabileau-6/+6
Also fixes `HashSet`'s that incorrectly designated itself as a `list`. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/coll/hm): Reword `extract_if` to use `element` instead of `value`Paul Mabileau-3/+3
A minor change, but it seemed interesting to unify this one's description, especially considering all the other equivalents use `element` as well. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-16additional edge cases tests for `path.rs`GrantBirki-1/+107
2025-05-16Remove #![feature(let_chains)] from library and src/librustdocest31-1/+0
2025-05-16disable the stack overflow handler on mirijoboet-29/+41
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-14Update std doctests for androidEric Huss-6/+21
This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2025-05-15Fix confusing WTF surrogate safety docsteor-6/+6
2025-05-14wire up startupinfo methodsFederico Terzi-0/+72
2025-05-14Move applicable float tests from `coretests` back to `std`Trevor Gross-0/+1166
The previous commit moved all test files from `std` to `core` so git understands the move. Not all functionality is actually testable in `core`, however, so perform move the relevant portions back. Changes from inherent to module methods is also done since this is the form of math operations available in `core` (as `core_float_math`).
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-13Move float tests from std to coreTrevor Gross-3994/+0
Many float-related tests in `std` only depend on `core`, so move the tests there. This also allows us to verify functions from `core_float_math`. Since the majority of test files need to be moved to `coretests`, move the files here without any cleanup; this is done in a followup commit. This makes git history slightly cleaner, but coretests will not build immediately after this commit.
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-13`impl PartialEq<{str,String}> for {Path,PathBuf}`Martin Habovstiak-0/+65
Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: https://github.com/rust-lang/libs-team/issues/151
2025-05-13bump compiler_builtinsPietro Albini-1/+1
2025-05-12update cfg(bootstrap)Pietro Albini-338/+184
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-07Rollup merge of #140734 - ivmarkov:master, r=joboetGuillaume Gomez-0/+1
Fix regression from #140393 for espidf / horizon / nuttx / vita #140393 introduced changes to the layout of the `std::sys::process` code. As a result, the Tier 3 ESP-IDF (and I suspect Horizon, Nuttx and Vita targets as well) no longer build. A `pub use unsupported::output` is all that was missing - for the above OSes specifically. This explicit `pub use` is now necessary, because #140393 moved the `output` function to module-level, where it was previously part of `Command` and was thus re-exported automatically, as part of the `imp::Command` re-export further down the file containing the one-liner fix. Note that - with the change introduced by #140393 - we **can't** anymore just do an unconditional `pub use imp::output` as this function simply does not exist anymore anywhere else but in the `unsupported` module. r? `@joboet`
2025-05-07Rollup merge of #140724 - tgross35:update-builtins, r=tgross35Guillaume Gomez-1/+1
Update `compiler-builtins` to 0.1.158 Includes the following changes: * Require `target_has_atomic = "ptr"` for runtime feature detection [1] [1]: https://github.com/rust-lang/compiler-builtins/pull/909
2025-05-07Rollup merge of #140398 - Berrysoft:cygwin-backtrace, r=tgross35Guillaume Gomez-1/+1
Fix backtrace for cygwin Closes #140304 Depends on: - [x] https://github.com/rust-lang/backtrace-rs/pull/704 This PR could not be merged until the above PR is merged. I'll update the submodule then. EDIT: submodule updated.
2025-05-07Fix regression from #140393 for espidf / horizon / nuttx / vitaivmarkov-0/+1
2025-05-07Fix backtrace for cygwin王宇逸-1/+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-06Update `compiler-builtins` to 0.1.158Trevor Gross-1/+1
Includes the following changes: * Require `target_has_atomic = "ptr"` for runtime feature detection [1]: https://github.com/rust-lang/compiler-builtins/pull/909
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-06Rollup merge of #139764 - dtolnay:extractif, r=AmanieuStuart Cook-22/+17
Consistent trait bounds for ExtractIf Debug impls Closes #137654. Refer to that issue for a table of the **4** different impl signatures we previously had in the standard library for Debug impls of various ExtractIf iterator types. The one we are standardizing on is the one so far only used by `alloc::collections::linked_list::ExtractIf`, which is _no_ `F: Debug` bound, _no_ `F: FnMut` bound, only `T: Debug` bound. This PR applies the following signature changes: ```diff /* alloc::collections::btree_map */ pub struct ExtractIf<'a, K, V, F, A = Global> where - F: 'a + FnMut(&K, &mut V) -> bool, Allocator + Clone, impl Debug for ExtractIf<'a, K, V, F, + A, > where K: Debug, V: Debug, - F: FnMut(&K, &mut V) -> bool, + A: Allocator + Clone, ``` ```diff /* alloc::collections::btree_set */ pub struct ExtractIf<'a, T, F, A = Global> where - T: 'a, - F: 'a + FnMut(&T) -> bool, Allocator + Clone, impl Debug for ExtractIf<'a, T, F, A> where T: Debug, - F: FnMut(&T) -> bool, A: Allocator + Clone, ``` ```diff /* alloc::collections::linked_list */ impl Debug for ExtractIf<'a, T, F, + A, > where T: Debug, + A: Allocator, ``` ```diff /* alloc::vec */ impl Debug for ExtractIf<'a, T, F, A> where T: Debug, - F: Debug, A: Allocator, - A: Debug, ``` ```diff /* std::collections::hash_map */ pub struct ExtractIf<'a, K, V, F> where - F: FnMut(&K, &mut V) -> bool, impl Debug for ExtractIf<'a, K, V, F> where + K: Debug, + V: Debug, - F: FnMut(&K, &mut V) -> bool, ``` ```diff /* std::collections::hash_set */ pub struct ExtractIf<'a, T, F> where - F: FnMut(&T) -> bool, impl Debug for ExtractIf<'a, T, F> where + T: Debug, - F: FnMut(&T) -> bool, ``` I have made the following changes to bring these types into better alignment with one another. - Delete `F: Debug` bounds. These are especially problematic because Rust closures do not come with a Debug impl, rendering the impl useless. - Delete `A: Debug` bounds. Allocator parameters are unstable for now, but in the future this would become an API commitment that we do not debug-print a representation of the allocator when printing an iterator. - Delete `F: FnMut` bounds. Requires `hashbrown` PR: https://github.com/rust-lang/hashbrown/pull/616. **API commitment:** we commit to not doing RefCell voodoo inside ExtractIf to have some way for its Debug impl (which takes &amp;self) to call a FnMut closure, if this is even possible. - Add `T: Debug` bounds (or `K`/`V`), even on Debug impls that do not currently make use of them, but might in the future. **Breaking change.** Must backport into Rust 1.87 (current beta) or do a de-stabilization PR in beta to delay those types by one release. - Render using `debug_struct` + `finish_non_exhaustive`, instead of `debug_tuple`. - Do not render the _entire_ underlying collection. - Show a "peek" field indicating the current position of the iterator.
2025-05-05Consistent trait bounds for ExtractIf Debug implsDavid Tolnay-22/+17
2025-05-05std: stop using TLS in signal handlerjoboet-38/+183
TLS is not async-signal-safe, making its use in the signal handler used to detect stack overflows unsound (c.f. #133698). POSIX however lists two thread-specific identifiers that can be obtained in a signal handler: the current `pthread_t` and the address of `errno`. Since `pthread_equal` is not AS-safe, `pthread_t` should be considered opaque, so for our purposes, `&errno` is the only option. This however works nicely: we can use the address as a key into a map that stores information for each thread. This PR uses a `BTreeMap` protected by a spin lock to hold the guard page address and thread name and thus fixes #133698.
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)