about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-06-26Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrumbors-90/+1198
Add more constants, functions, and tests for `f16` and `f128` This adds everything that was in some way blocked on const eval, since https://github.com/rust-lang/rust/pull/126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change. `f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64. Tracking issue: https://github.com/rust-lang/rust/issues/116909
2024-06-25std: test a variety of ways to extend a Wtf8BufJubilee Young-0/+24
2024-06-25set self.is_known_utf8 to false in extend_from_sliceash-1/+1
2024-06-25std: separate TLS key creation from TLS accessjoboet-125/+100
Currently, `std` performs an atomic load to get the OS key on every access to `StaticKey` even when the key is already known. This PR thus replaces `StaticKey` with the platform-specific `get` and `set` function and a new `LazyKey` type that acts as a `LazyLock<Key>`, allowing the reuse of the retreived key for multiple accesses.
2024-06-25`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms ↵ash-27/+42
#126333
2024-06-25remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension`ash-6/+5
2024-06-25inner truncate methods for UEFI platformsash-3/+13
2024-06-25#126333 remove `PathBuf::as_mut_vec` reference at top of `PathBuf::_push`ash-1/+2
2024-06-25Add tests for `f16` and `f128`Trevor Gross-35/+1029
This suite tests all library functions that are now available for the types. Tests are only run on certain platforms where `f16` and `f128` are known to work (have symbols available and don't crash LLVM).
2024-06-25Add more `f16` and `f128` library functions and constantsTrevor Gross-0/+59
This adds everything that was directly or transitively blocked on const arithmetic for these types, which was recently merged. Since const arithmetic is recent, most of these need to be gated by `bootstrap`. Anything that relies on intrinsics that are still missing is excluded.
2024-06-25Check that we get somewhat sane PIDs when spawning with pidfdsThe 8472-0/+3
2024-06-25more fine-grained feature-detection for pidfd spawningThe 8472-21/+33
we now distinguish between pidfd_spawn support, pidfd-via-fork/exec and not-supported
2024-06-25document safety properties of the internal Process::new constructorThe 8472-0/+6
2024-06-25use pidfd_spawn for faster process creation when pidfds are requestedThe 8472-6/+106
2024-06-25document the cvt methodsThe 8472-0/+4
2024-06-24Rollup merge of #125082 - kpreid:const-uninit, r=dtolnayMichael Goulet-6/+4
Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks. \[This PR originally contained the changes in #125995 too. See edit history for the original PR description.] The documentation of `MaybeUninit::uninit_array()` says: > Note: in a future Rust version this method may become unnecessary when Rust allows [inline const expressions](https://github.com/rust-lang/rust/issues/76001). The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`. The PR adding it also said: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a standard library method that will be replaceable with `let buffer = [MaybeUninit::<T>::uninit(); $N];` That time has come to pass — inline const expressions are stable — so `MaybeUninit::uninit_array()` is now unnecessary. The only remaining question is whether it is an important enough *convenience* to keep it around. I believe it is net good to remove this function, on the principle that it is better to compose two orthogonal features (`MaybeUninit` and array construction) than to have a specific function for the specific combination, now that that is possible.
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-6/+4
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-06-24Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrumbors-928/+733
std: refactor the TLS implementation As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. `@rustbot` label +A-thread-locals
2024-06-24std: fix wasm buildsjoboet-2/+16
2024-06-23wasm64 build with target-feature=+simd128,+atomicswooden-worm-10/+16
2024-06-24Extract repeated constants from `f32` and `f64` sourceTrevor Gross-55/+110
This will make it easier to keep `f16` and `f128` consistent as their implementations get added.
2024-06-24Rollup merge of #126854 - devnexen:std_unix_os_fallback_upd, r=Mark-SimulacrumMatthias Krüger-3/+3
std::unix::os::home_dir: fallback's optimisation. we're using a guaranteed initialised field on success.
2024-06-24Rollup merge of #126807 - devnexen:copy_file_macos_simpl, r=Mark-SimulacrumMatthias Krüger-35/+15
std::unix::fs: copy simplification for apple. since we do support from macOs Sierra, we avoid the little runtime overhead with the fclonefileat symbol check.
2024-06-23fix buildDavid Carlier-2/+1
2024-06-23Rollup merge of #126783 - ↵Matthias Krüger-5/+5
tguichaoua:fix_tcplistener_into_incoming_issue_number, r=workingjubilee Fix issue number for the `tcplistener_into_incoming` feature As per [this comment](https://github.com/rust-lang/rust/pull/88339#discussion_r922899044), the issue number for the `tcplistener_into_incoming` feature is the one of the PR that implements it instead of the tracking issue. - https://github.com/rust-lang/rust/pull/88339 - https://github.com/rust-lang/rust/issues/88373
2024-06-23std::unix::os::home_dir: fallback's optimisation.David Carlier-2/+3
we're using a guaranteed initialised field on success.
2024-06-22Rollup merge of #126552 - fee1-dead-contrib:rmfx, r=compiler-errorsMatthias Krüger-1/+0
Remove use of const traits (and `feature(effects)`) from stdlib The current uses are already unsound because they are using non-const impls in const contexts. We can reintroduce them by reverting the commit in this PR, after #120639 lands. Also, make `effects` an incomplete feature. cc `@rust-lang/project-const-traits` r? `@compiler-errors`
2024-06-22Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=AmanieuMatthias Krüger-19/+18
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists FCP completed in tracking issue. Tracking issue: https://github.com/rust-lang/rust/issues/83186 Closes https://github.com/rust-lang/rust/issues/83186 Stabilized API: ```rust mod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>; } ```
2024-06-22Auto merge of #124101 - the8472:pidfd-methods, r=cuviperbors-124/+265
Add PidFd::{kill, wait, try_wait} #117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: #82971
2024-06-22to extract a pidfd we must consume the childThe 8472-12/+19
As long as a pidfd is on a child it can be safely reaped. Taking it would mean the child would now have to be awaited through its pid, but could also be awaited through the pidfd. This could then suffer from a recycling race.
2024-06-22Add PidFd::{kill, wait, try_wait}The 8472-117/+251
2024-06-21std::unix::fs: copy simplification for apple.David Carlier-35/+15
since we do support from macOs Sierra, we avoid the little runtime overhead with the fclonefileat symbol check.
2024-06-21Remove `feature(effects)` from the standard libraryDeadbeef-1/+0
2024-06-21fix issue numberTristan Guichaoua-5/+5
2024-06-20Don't perform mitigation for thread-unsafe libc::exit under Miri.Zachary S-1/+9
1. Miri's exit is thread-safe 2. Miri doesn't (yet) support `libc::gettid`, used in the implementation of the mitigation on Linux.
2024-06-20fix rustdoc URLZachary S-3/+4
2024-06-20On `target_os = "linux"`, ensure that only one Rust thread calls ↵Zachary S-0/+93
`libc::exit` or returns from `main`.
2024-06-20Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgrbors-12/+22
Rollup of 7 pull requests Successful merges: - #126380 (Add std Xtensa targets support) - #126636 (Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s ) - #126659 (More status-quo tests for the `#[coverage(..)]` attribute) - #126711 (Make Option::as_[mut_]slice const) - #126717 (Clean up some comments near `use` declarations) - #126719 (Fix assertion failure for some `Expect` diagnostics.) - #126730 (Add opaque type corner case test) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-20Stabilize `PanicInfo::message()` and `PanicMessage`StackOverflowExcept1on-1/+0
2024-06-19Stabilize `hint_assert_unchecked`Trevor Gross-1/+0
Make both `hint_assert_unchecked` and `const_hint_assert_unchecked` stable as `hint_assert_unchecked`.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+8
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-20Convert some module-level `//` and `///` comments to `//!`.Nicholas Nethercote-12/+14
This makes their intent and expected location clearer. We see some examples where these comments were not clearly separate from `use` declarations, which made it hard to understand what the comment is describing.
2024-06-19Stabilise c_unwindGary Guo-1/+1
2024-06-18Replace `move||` with `move ||` in `compiler/` and `library/`Vonr-16/+16
Edit from #126631 to revert changes on ui tests
2024-06-17Add PanicMessage type for PanicInfo::message().Mara Bos-5/+8
2024-06-17std: rename module for clarityjoboet-2/+2
2024-06-17std: update TLS module documentationjoboet-16/+22
2024-06-17std: use the `c_int` from `core::ffi` instead of `libc`joboet-1/+1
2024-06-17std: simplify `#[cfg]`s for TLSjoboet-15/+10
2024-06-17Rollup merge of #126346 - hermit-os:fd, r=Amanieu许杰友 Jieyou Xu (Joe)-13/+4
export std::os::fd module on HermitOS The HermitOS' IO interface is similiar to Unix. Consequently, this PR synchronize the FD implementation between both. closes #126198