about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-01-31improve doc tests for (min/max/minmax).* functionsWaffle Lapkin-18/+128
- add tests for `a == b` where missing - try to make all the tests more similar - try to use more illustrative test values
2025-01-30Rollup merge of #136271 - Sky9x:debug-maybeuninit-footgun, r=tgross35Matthias Krüger-3/+2
Remove minor future footgun in `impl Debug for MaybeUninit` No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen) Debug impl originally added in #133282
2025-01-30Rollup merge of #135852 - lukas-code:asyncfn-prelude-core, r=compiler-errorsMatthias Krüger-0/+3
Add `AsyncFn*` to `core` prelude In https://github.com/rust-lang/rust/pull/132611 these got added to the `std` prelude only, which looks like an oversight. r? libs-api cc `@compiler-errors`
2025-01-30Auto merge of #134824 - niklasf:int_from_ascii, r=ibraheemdevbors-89/+131
Implement `int_from_ascii` (#134821) Provides unstable `T::from_ascii()` and `T::from_ascii_radix()` for integer types `T`, as drafted in tracking issue #134821. To deduplicate documentation without additional macros, implementations of `isize` and `usize` no longer delegate to equivalent integer types. After #132870 they are inlined anyway.
2025-01-30atomic: extend compare_and_swap migration docsRalf Jung-0/+18
2025-01-30float::min/max: mention the non-determinism around signed 0Ralf Jung-8/+16
2025-01-30Rollup merge of #136259 - hkBst:patch-30, r=thomccStuart Cook-31/+27
Cleanup docs for Allocator This is an attempt to remove ungrammatical constructions and clean up the prose. I've sometimes had to try hard to understand what was being stated, so it is possible that I've misunderstood the original meaning. In particular, I did not see a difference between: - the borrow-checker lifetime of the allocator type itself. - as long as at least one of the allocator instance and all of its clones has not been dropped.
2025-01-30Rollup merge of #135847 - edwloef:slice_ptr_rotate_opt, r=scottmcmStuart Cook-152/+182
optimize slice::ptr_rotate for small rotates r? `@scottmcm` This swaps the positions and numberings of algorithms 1 and 2 in `slice::ptr_rotate`, and pulls the entire outer loop into algorithm 3 since it was redundant for the first two. Effectively, `ptr_rotate` now always does the `memcpy`+`memmove`+`memcpy` sequence if the shifts fit into the stack buffer. With this change, an `IndexMap`-style `move_index` function is optimized correctly. Assembly comparisons: - `move_index`, before: https://godbolt.org/z/Kr616KnYM - `move_index`, after: https://godbolt.org/z/1aoov6j8h - the code from `#89714`, before: https://godbolt.org/z/Y4zaPxEG6 - the code from `#89714`, after: https://godbolt.org/z/1dPx83axc related to #89714 some relevant discussion in https://internals.rust-lang.org/t/idea-shift-move-to-efficiently-move-elements-in-a-vec/22184 Behavior tests pass locally. I can't get any consistent microbenchmark results on my machine, but the assembly diffs look promising.
2025-01-29Remove minor future footgun in `impl Debug for MaybeUninit`Sky-3/+2
No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen)
2025-01-29Cleanup docs for AllocatorMarijn Schouten-31/+27
2025-01-29add inline attribute and codegen testedwloef-0/+4
2025-01-29split slice::ptr_rotate into three separate algorithms, to hopefully help ↵edwloef-174/+195
inlining
2025-01-28Fix off-by-one error causing driftsort to crashuellenberg-8/+22
Fixes #136103. Based on the analysis by @jonathan-gruber-jg and @orlp.
2025-01-29Rollup merge of #135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhprattLeón Orell Valerian Liehr-0/+11
[cfg_match] Document the use of expressions. cc #115585 Adds documentation to this new feature introduced in #133720.
2025-01-28Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgrbors-8/+10
Rollup of 9 pull requests Successful merges: - #135869 (Make docs for AtomicUsize::from_mut platform-independent) - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`) - #136055 (Implement MIR const trait stability checks) - #136066 (Pass spans to `perform_locally_in_new_solver`) - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items) - #136124 (Arbitrary self types v2: explain test.) - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order) - #136173 (Update comments and sort target_arch in c_char_definition) - #136178 (Update username in build helper example) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Rollup merge of #136173 - taiki-e:c-char, r=tgross35Matthias Krüger-7/+9
Update comments and sort target_arch in c_char_definition Follow-up to https://github.com/rust-lang/rust/pull/132975. - Clang's wrong default on MSP430 has been fixed in https://github.com/llvm/llvm-project/pull/115964, and will be included in LLVM 20, which will be used soon. - Add a reference on Xtensa's default (from https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240). - Fix link for Windows's default. - Add a link to the discussion on L4Re (https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240) - Sort `target_arch`. (now match with `target_arch`s in comments) r? `@tgross35`
2025-01-28Rollup merge of #135869 - hkBst:patch-12, r=NoratriebMatthias Krüger-1/+1
Make docs for AtomicUsize::from_mut platform-independent fixes #133342
2025-01-28Stabilize `get_many_mut` as `get_disjoint_mut`Pavel Grigorenko-61/+58
* Renames the methods: * `get_many_mut` -> `get_disjoint_mut` * `get_many_unchecked_mut` -> `get_disjoint_unchecked_mut` * Does not rename the feature flag: `get_many_mut` * Marks the feature as stable * Renames some helper stuff: * `GetManyMutError` -> `GetDisjointMutError` * `GetManyMutIndex` -> `GetDisjointMutIndex` * `get_many_mut_helpers` -> `get_disjoint_mut_helpers` * `get_many_check_valid` -> `get_disjoint_check_valid` This only touches slice methods. HashMap's methods and feature gates are not renamed here (nor are they stabilized).
2025-01-28Rollup merge of #135886 - hkBst:patch-14, r=workingjubileeMatthias Krüger-2/+2
Document purpose of closure in from_fn.rs more clearly partial fix for #135087 together with https://github.com/rust-lang/rust/pull/135895
2025-01-28Rollup merge of #133829 - GrigorenkoPV:fetch_update_infallible, r=NoratriebMatthias Krüger-3/+374
Implement `AtomicT::update` & `AtomicT::try_update` ACP accepted in https://github.com/rust-lang/libs-team/issues/490 ``@rustbot`` label +T-libs-api
2025-01-28Fix platform-specific doc string for AtomicUsize::from_mut to be ↵Marijn Schouten-1/+1
platform-independent
2025-01-28Update comments and sort target_arch in c_char_definitionTaiki Endo-7/+9
2025-01-27Stabilize target_feature_11Caleb Zulawski-1/+0
2025-01-27Stabilize `num_midpoint_signed` featureUrgau-4/+4
2025-01-27Rollup merge of #135807 - jhpratt:phantom-variance, r=AmanieuGuillaume Gomez-0/+267
Implement phantom variance markers ACP accepted https://github.com/rust-lang/libs-team/issues/488 Tracking issue #135806
2025-01-27Rollup merge of #135773 - hkBst:patch-10, r=tgross35Guillaume Gomez-4/+9
Clarify WindowsMut (Lending)Iterator fixes #133628
2025-01-27Clarify WindowsMut (Lending)IteratorMarijn Schouten-4/+9
fixes 133628
2025-01-27Stabilize `const_black_box`Trevor Gross-1/+4
This has been unstably const since [1], but a tracking issue was never created. Per discussion on Zulip [2], there should not be any blockers to making this const-stable. The function does not provide any functionality at compile time but does allow code reuse between const- and non-const functions, so stabilize it here. [1]: https://github.com/rust-lang/rust/pull/92226 [2]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2025-01-27Auto merge of #136116 - fmease:rollup-c8pk3mj, r=fmeasebors-13/+13
Rollup of 8 pull requests Successful merges: - #126604 (Uplift `clippy::double_neg` lint as `double_negations`) - #135158 (Add `TooGeneric` variant to `LayoutError` and emit `Unknown`) - #135635 (Move `std::io::pipe` code into its own file) - #136072 (add two old crash tests) - #136079 (compiler_fence: fix example) - #136091 (Add some tracing to core bootstrap logic) - #136097 (rustc_ast: replace some len-checks + indexing with slice patterns etc.) - #136101 (triagebot: set myself on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-27Auto merge of #135937 - bjorn3:separate_coretests_crate, r=jieyouxu,tgross35bors-1/+1
Put the core unit tests in a separate coretests package Having standard library tests in the same package as a standard library crate has bad side effects. It causes the test to have a dependency on a locally built standard library crate, while also indirectly depending on it through libtest. Currently this works out fine in the context of rust's build system as both copies are identical, but for example in cg_clif's tests I've found it basically impossible to compile both copies with the exact same compiler flags and thus the two copies would cause lang item conflicts. This PR moves the tests of libcore to a separate package which doesn't depend on libcore, thus preventing the duplicate crates even when compiler flags don't exactly match between building the sysroot (for libtest) and building the test itself. The rest of the standard library crates do still have this issue however.
2025-01-27Rollup merge of #136079 - RalfJung:compiler-fence-example, r=jhprattLeón Orell Valerian Liehr-13/+13
compiler_fence: fix example The old example was wrong, an acquire fence is required in the signal handler. To make the point more clear, I changed the "data" variable to use non-atomic accesses. Fixes https://github.com/rust-lang/rust/issues/133014
2025-01-26compiler_fence: fix exampleRalf Jung-13/+13
2025-01-26Document purpose of closure in from_fn.rs more clearlyMarijn Schouten-2/+2
2025-01-26Update commentbjorn3-1/+1
2025-01-26Rollup merge of #136019 - scottmcm:alias-unchecked-div, r=Mark-SimulacrumJacob Pratt-0/+7
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls Inspired by https://github.com/rust-lang/libs-team/issues/526, if people are looking for `unchecked_div`, point them to `u32: Div<NonZero<u32>>` and friends which do no runtime checks -- and are safe! -- rather than today's behaviour of [the intrinsic being the top result](https://doc.rust-lang.org/std/?search=unchecked_div). ![image](https://github.com/user-attachments/assets/cf2a3c06-4876-49c1-8e33-64cd431c772a)
2025-01-26Implement phantom variance markersJacob Pratt-0/+267
2025-01-25Rollup merge of #136039 - nvanbenschoten:pin-typo, r=AmanieuMatthias Krüger-2/+2
docs: fix typo in std::pin overview Unimportant fix in `std::pin` documentation.
2025-01-25Rollup merge of #136005 - BLANKatGITHUB:library, r=RalfJungMatthias Krüger-677/+957
ports last few library files to new intrinsic style This pr ports the last 2 library files to new intrinsic style this pr is part of issue #132735
2025-01-25Rollup merge of #135977 - nyurik:fix-fmt-options, r=joboetMatthias Krüger-1/+10
Fix `FormattingOptions` instantiation with `Default` The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`. Note that `FormattingOptions` is being released as part of 1.85 (unstable) - so this might warrant a backport to that branch. Tracking issue: https://github.com/rust-lang/rust/issues/118117 Follow up from https://github.com/rust-lang/rust/pull/118159 CC: ``@EliasHolzmann`` ``@programmerjake`` r? ``@m-ou-se``
2025-01-24docs: fix typo in std::pin overviewNathan VanBenschoten-2/+2
2025-01-25Remove unused trait BoundedSizeMu001999-55/+0
2025-01-24Rollup merge of #135938 - carlsverre:master, r=joboetMatthias Krüger-0/+20
Add memory layout documentation to generic NonZero<T> The documentation I've added is based on the same Layout documentation that appears on the other `NonZero*` types. For example see [the Layout docs on `NonZeroI8`](https://doc.rust-lang.org/std/num/type.NonZeroI8.html#layout-1).
2025-01-24Add an `unchecked_div` alias to the `Div<NonZero<_>>` implsScott McMurray-0/+7
2025-01-24Update library/core/src/num/nonzero.rs Carl Sverre-1/+1
Tweak language Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2025-01-24ports last few library files to new intrinsic styleaaishwarymishra@gmail.com-677/+957
2025-01-24Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35Matthias Krüger-1/+0
remove pointless allowed_through_unstable_modules on TryFromSliceError This got added in https://github.com/rust-lang/rust/pull/132482 but the PR does not explain why. `@lukas-code` do you still remember? Also Cc `@Noratrieb` as reviewer of that PR. If I understand the issue description correctly, all paths under which this type is exported are stable now: `core::array::TryFromSliceError` and `std::array::TryFromSliceError`. If that is the case, we shouldn't have the attribute; it's a terrible hack that should only be used when needed to maintain backward compatibility. Getting some historic information right is IMO *not* sufficient justification to risk accidentally exposing this type via more unstable paths today or in the future.
2025-01-24Fix `FormattingOptions` instantiation with `Default`Yuri Astrakhan-1/+10
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+595
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-23Add memory layout documentation to generic NonZero<T>Carl Sverre-0/+20
2025-01-22Implement `AtomicT::update` & `AtomicT::try_update`Pavel Grigorenko-3/+374