about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-05-20`core_float_math`: Move functions to `math` folderDaniel McNab-933/+990
When these functions were added in https://github.com/rust-lang/rust/pull/138087 It made a relatively common pattern for emulating these functions using an extension trait (which internally uses `libm`) much more fragile. If `core::f32` happened to be imported by the user (to access a constant, say), then that import in the module namespace would take precedence over `f32` in the type namespace for resolving these functions, running headfirst into the stability attribute. We ran into this in Color - https://github.com/linebender/color - and chose to release the remedial 0.3.1 and 0.2.4, to allow downstream crates to build on `docs.rs`. As these methods are perma-unstable, moving them into a new module should not have any long-term concerns, and ensures that this breakage doesn't adversely impact anyone else.
2025-05-20in `intrinsic-test`, format f16 like CFolkert de Vries-1/+102
2025-05-20use the right load instructionFolkert de Vries-3/+3
2025-05-20`avx512_target_feature` is now stable on nightlyFolkert de Vries-3/+0
2025-05-20use Self alias in self types rather than manually substituting itMichael Goulet-5/+5
2025-05-20Split `autodiff` into `autodiff_forward` and `autodiff_reverse`Marcelo Domínguez-1/+15
Pending fix. ``` error: cannot find a built-in macro with name `autodiff_forward` --> library\core\src\macros\mod.rs:1542:5 | 1542 | / pub macro autodiff_forward($item:item) { 1543 | | /* compiler built-in */ 1544 | | } | |_____^ error: cannot find a built-in macro with name `autodiff_reverse` --> library\core\src\macros\mod.rs:1549:5 | 1549 | / pub macro autodiff_reverse($item:item) { 1550 | | /* compiler built-in */ 1551 | | } | |_____^ error: could not compile `core` (lib) due to 2 previous errors ```
2025-05-20make std::intrinsic functions actually be intrinsicsRalf Jung-303/+309
2025-05-20Rollup merge of #141211 - fluiderson:dev, r=thomccStuart Cook-2/+1
Replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read` This change restores the previous behavior prior to #117925. That PR was made to handle OOM errors that turn into a panic with `Vec::with_capacity`. `try_reserve_exact` was used for that since there was no `try_with_capacity` method at the time. It was added later in #120504. I think it'd a better fit here.
2025-05-19Auto merge of #138023 - melrief:97227_impl_Seek_for_Take, r=tgross35bors-1/+173
Add `std::io::Seek` instance for `std::io::Take` Library tracking issue [#97227](https://github.com/rust-lang/rust/issues/97227). ACP: https://github.com/rust-lang/libs-team/issues/555 1. add a `len` field to `Take` to keep track of the original number of bytes that `Take` could read 2. add a `position()` method to return the current position of the cursor inside `Take` 3. implement `std::io::Seek` for `std::io::Take` Closes: https://github.com/rust-lang/libs-team/issues/555
2025-05-19Rollup merge of #141248 - RalfJung:reentrant-lock-race, r=joboetMatthias Krüger-2/+6
fix data race in ReentrantLock fallback for targets without 64bit atomics See [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/reentrant.20lock.20failure.20on.20musl) for details: the address used to identify a thread might get lazily allocated inside `tls_addr()`, so if we call that *after* doing the `tls_addr.load()` it is too late to establish synchronization with prior threads that used the same address -- the `load()` thus races with the `store()` by that prior thread, and might hence see outdated values, and then the entire logic breaks down. r? `@joboet`
2025-05-19Add `std::io::Seek` instance for `std::io::Take`Mario Pastorelli-1/+173
2025-05-19windows: document that we rely on an undocumented property of ↵Ralf Jung-0/+2
GetUserProfileDirectoryW
2025-05-19fix data race in ReentrantLock fallback for targets without 64bit atomicsRalf Jung-2/+6
2025-05-18add exact_div functionsJeremy Smart-1/+207
2025-05-19Rollup merge of #141110 - xizheyin:issue-141107, r=workingjubileeStuart Cook-2/+2
[std] fix the presentation of `split_off_mut` and `split_off` documentation Fixes #141107 r? libs
2025-05-18Auto merge of #127013 - tgross35:f16-format-parse, r=Mark-Simulacrumbors-81/+614
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: x86_64-gnu-aux
2025-05-18float: Add tests for `f16` conversions to and from decimalTrevor Gross-77/+501
Extend the existing tests for `f32` and `f64` with versions that include `f16`'s new printing and parsing implementations. Co-authored-by: Speedy_Lex <alex.ciocildau@gmail.com>
2025-05-18Rollup merge of #140628 - joboet:async_signal_safe, r=Mark-SimulacrumLeón Orell Valerian Liehr-58/+215
std: stop using TLS in signal handler 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-18Rollup merge of #138940 - sayantn:stabilize-avx512, r=Amanieu,traviscrossLeón Orell Valerian Liehr-1/+1
Stabilize the avx512 target features This PR stabilizes the AVX512 target features - see [this comment](https://github.com/rust-lang/rust/issues/111137#issuecomment-2745821279). Tracking Issue - #44839 The target feature UI tests have been changed to `x87` (chosen because this is very unlikely to stablize ever, please comment if some other feature will be better) related: #111137
2025-05-18float: Add `f16` parsing and printingTrevor Gross-4/+113
Use the existing Lemire (decimal -> float) and Dragon / Grisu algorithms (float -> decimal) to add support for `f16`. This allows updating the implementation for `Display` to the expected behavior for `Display` (currently it prints the a hex bitwise representation), matching other floats, and adds a `FromStr` implementation. In order to avoid crashes when compiling with Cranelift or on targets where f16 is not well supported, a fallback is used if `cfg(target_has_reliable_f16)` is not true.
2025-05-18Merge `compiler-builtins` as a Josh subtreeTrevor Gross-0/+52997
Use the Josh [1] utility to add `compiler-builtins` as a subtree, which will allow us to stop using crates.io for updates. This is intended to help resolve some problems when unstable features change and require code changes in `compiler-builtins`, which sometimes gets trapped in a bootstrap cycle. This was done using `josh-filter` built from the r24.10.04 tag: git fetch https://github.com/rust-lang/compiler-builtins.git 233434412fe7eced8f1ddbfeddabef1d55e493bd josh-filter ":prefix=library/compiler-builtins" FETCH_HEAD git merge --allow-unrelated FILTERED_HEAD The HEAD in the `compiler-builtins` repository is 233434412f ("fix an if statement that can be collapsed"). [1]: https://github.com/josh-project/josh
2025-05-18[std] fix the presentation of `split_off_mut` and `split_off` documentationxizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-18fix an if statement that can be collapsedFolkert de Vries-19/+21
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-18Rollup merge of #140924 - Urgau:f32_f64_const_tests, r=Mark-SimulacrumLeón Orell Valerian Liehr-143/+189
Make some `f32`/`f64` tests also run in const-context
2025-05-18Rollup merge of #140511 - mathisbot:master, r=dtolnayLeón Orell Valerian Liehr-3/+4
Stabilize `#![feature(non_null_from_ref)]` This PR stabilizes the following: ```rust impl<T: ?Sized> NonNull<T> { pub const fn from_ref(reference: &T) -> NonNull<T>; pub const fn from_mut(reference: &mut T) -> NonNull<T>; } ``` The feature is tracked in [#130823](https://github.com/rust-lang/rust/issues/130823).
2025-05-18replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read`Fluid-2/+1
2025-05-18Stabilize `avx512_target_feature`sayantn-1/+1
2025-05-17Auto merge of #138087 - tgross35:core-float-math, r=Amanieubors-3704/+4711
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-17remove extra tests that really might not be all that usefulGrantBirki-55/+0
2025-05-17Correct rustc version for the stabilization of runtime detection of VEX ↵sayantn-5/+5
variants of avx512
2025-05-17revert forward slash to backslashGrantBirki-1/+1
2025-05-17Rollup merge of #139103 - joboet:abort_dedup, r=tgross35Matthias Krüger-117/+42
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-17Rollup merge of #137432 - djscythe:char_u8_str_as_ascii_unchecked, r=scottmcmMatthias Krüger-0/+63
Add as_ascii_unchecked() methods to char, u8, and str This PR adds the `as_ascii_unchecked()` method to `char`, `u8`, and `str`, allowing users to convert these types to `ascii::Char`s (see #110998) in an `unsafe` context without first checking for validity. This method was already available for `[u8]`, so this PR makes the API more consistent across other types.
2025-05-17Switch library rustc_unimplemented to use `Self` and `This`mejrs-70/+67
2025-05-17Stabilize runtime detection of VEX variants of avx512sayantn-5/+5
2025-05-17Rollup merge of #140957 - JulianKnodt:array_must_use, r=Mark-SimulacrumMatthias Krüger-1/+2
Add `#[must_use]` to Array::map The output of Array::map is intended to be an array of the same size, and does not modify the original in place nor is it intended for side-effects. Thus, under normal circumstances it should be consumed. See [discussion](https://internals.rust-lang.org/t/array-map-annotate-with-must-use/22813/26). Attaching to tracking issue #75243
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/extract_if): Unify example descriptionPaul Mabileau-2/+2
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
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-6/+6
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-12/+12
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/btm): Split `extract_if`'s first sentence from the following onesPaul Mabileau-4/+6
This also seems like a small mistake: the first main sentence is put in the same paragraph as the other two following ones while other equivalents all have it split. Therefore, do the same here. 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-17Docs(lib/alloc/vec): Add the missing `an` to `extract_if`'s first sentencePaul Mabileau-1/+1
As inspired by the equivalent methods from other collection types. 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-16Implement `advance_by` via `try_fold` for `Sized` iteratorsBenoît du Garreau-5/+31
When `try_fold` is overriden, it is usually easier for compilers to optimize.
2025-05-16Add assert_unsafe_precondition!()s to as_ascii_unchecked() methodssam skeoch-0/+20