about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-03Add test case demonstrating equality of paths "foo/bar" and "foobar"Zanie Blue-0/+7
2024-07-03Move unique_thread_exit call to lang_start_internal so it is not in a ↵Zachary S-3/+4
generic function, and wrap it in `catch_unwind`
2024-07-03Remove Miri special-caseZachary S-9/+1
2024-07-03Use pthread_t instead of numeric thread idZachary S-45/+12
2024-07-03Use libc::pause instead of std::thread::park in wait-for-exit loopZachary S-7/+10
2024-07-03Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnayJacob Pratt-1/+0
Stabilize `hint::assert_unchecked` Make the following API stable, including const: ```rust // core::hint, std::hint pub const unsafe fn assert_unchecked(p: bool); ``` This PR also reworks some of the documentation and adds an example. Tracking issue: https://github.com/rust-lang/rust/issues/119131 FCP: https://github.com/rust-lang/rust/issues/119131#issuecomment-1906394087. The docs update should resolve the remaining concern.
2024-07-03Fall back on remove dir implementation for vxworksB I Mohammed Abbas-1/+3
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-3/+3
chore: remove duplicate words remove duplicate words in comments to improve readability.
2024-07-02chore: remove duplicate wordshattizai-3/+3
2024-07-01Rollup merge of #126732 - StackOverflowExcept1on:master, r=m-ou-seGuillaume Gomez-1/+0
Stabilize `PanicInfo::message()` and `PanicMessage` Resolves #66745 This stabilizes the [`PanicInfo::message()`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicInfo.html#method.message) and [`PanicMessage`](https://doc.rust-lang.org/nightly/core/panic/struct.PanicMessage.html). Demonstration of [custom panic handler](https://github.com/StackOverflowExcept1on/panicker): ```rust #![no_std] #![no_main] extern crate libc; #[no_mangle] extern "C" fn main() -> libc::c_int { panic!("I just panic every time"); } #[panic_handler] fn my_panic(panic_info: &core::panic::PanicInfo) -> ! { use arrayvec::ArrayString; use core::fmt::Write; let message = panic_info.message(); let location = panic_info.location().unwrap(); let mut debug_msg = ArrayString::<1024>::new(); let _ = write!(&mut debug_msg, "panicked with '{message}' at '{location}'"); if debug_msg.try_push_str("\0").is_ok() { unsafe { libc::puts(debug_msg.as_ptr() as *const _); } } unsafe { libc::exit(libc::EXIT_FAILURE) } } ``` ``` $ cargo +stage1 run --release panicked with 'I just panic every time' at 'src/main.rs:8:5' ``` - [x] FCP: https://github.com/rust-lang/rust/issues/66745#issuecomment-2198143725 r? libs-api
2024-07-01Remove unqualified import io:: Error for vxworks as all Error references are ↵B I Mohammed Abbas-1/+1
qualified in process_vxworks.rs
2024-06-29Rollup merge of #126953 - joboet:lazy_key, r=jhprattMatthias Krüger-128/+115
std: separate TLS key creation from TLS access 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. Related to #110897.
2024-06-28std: add safety commentsjoboet-4/+16
2024-06-27Rollup merge of #126980 - Borgerr:fix-extendfromslice-check, r=workingjubileeJacob Pratt-1/+25
set self.is_known_utf8 to false in extend_from_slice try-job: x86_64-msvc closes #126977 Related to #126885, #126333, and [this conversation](<https://github.com/rust-lang/rust/commit/aa46a3368eb017eba41bfab956c7787d46c09935#r143539097>)
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