about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-12-01Rollup merge of #133678 - Urgau:stabilize-ptr_fn_addr_eq, r=jhprattJacob Pratt-3/+1
Stabilize `ptr::fn_addr_eq` This PR stabilize the `ptr::fn_addr_eq` function. FCP completed in https://github.com/rust-lang/rust/issues/129322#issuecomment-2508304516 Closes https://github.com/rust-lang/rust/issues/129322
2024-12-01Rollup merge of #133672 - RalfJung:const-stability-cleanup, r=jhprattJacob Pratt-32/+1
Remove a bunch of unnecessary const stability noise
2024-12-01Rollup merge of #131784 - Urgau:stabilize-midpoint, r=dtolnayJacob Pratt-36/+33
Stabilize unsigned and float variants of `num_midpoint` feature This PR proposes that we stabilize the unsigned variants of the [`num_midpoint`](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) feature as well as the floats variants, since they are not subject to any unresolved questions, which is equivalent to doing `(a + b) / 2` (and `(a + b) >> 1`) in a sufficiently large number. The stabilized API surface would be: ```rust /// Calculates the middle point of `self` and `rhs`. /// /// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a sufficiently-large unsigned integral type. /// This implies that the result is always rounded towards negative infinity and that no overflow will ever occur. impl u{8,16,32,64,128,size} { pub const fn midpoint(self, rhs: Self) -> Self; } impl NonZeroU{8,16,32,64,size} { pub const fn midpoint(self, rhs: Self) -> Self; } impl f{32,64} { pub const fn midpoint(self, rhs: Self) -> Self; } ``` The signed variants `u{8,16,32,64,128,size}` would remain gated, until a decision is made about the rounding mode, in other words that the [unresolved questions](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) are resolved. cc `@rust-lang/libs-api` cc `@scottmcm` r? libs-api
2024-12-01Rollup merge of #131416 - okaneco:const_copy, r=RalfJungJacob Pratt-6/+10
Mark `slice::copy_from_slice` unstably const Tracking issue #131415 I used `const_eval_select` for runtime and const panic functions because const formatting isn't available yet.
2024-12-01Mark `slice::copy_from_slice` unstably constokaneco-6/+10
2024-12-01Rollup merge of #133674 - scottmcm:chain-carrying-add, r=AmanieuMatthias Krüger-1/+1
Fix chaining `carrying_add`s Something about the MIR lowering for `||` ended up breaking this, but it's fixed by changing the code to use `|` instead. I also added an assembly test to ensure it *keeps* being [`adc`](https://www.felixcloutier.com/x86/adc). cc https://github.com/rust-lang/rust/issues/85532#issuecomment-2495119815, which noticed this.
2024-12-01Rollup merge of #133669 - RalfJung:const_swap_splitup, r=dtolnayMatthias Krüger-3/+3
Move some functions out of const_swap feature gate - `swap_unchecked` is still unstable as a regular fn, so that feature gate can also cover its constness. - `swap_nonoverlapping` isn't ready to be stabilized yet, so make it a different feature gate. Part of https://github.com/rust-lang/rust/issues/83163, https://github.com/rust-lang/rust/issues/88539, https://github.com/rust-lang/rust/issues/133668
2024-12-01Stabilize unsigned `num_midpoint` featureUrgau-36/+33
2024-12-01Rollup merge of #133686 - samueltardieu:push-xkxwxzxqokuu, r=compiler-errorsMatthias Krüger-0/+1
Add diagnostic item for `std::ops::ControlFlow` This will be used in Clippy to detect useless conversions done through `ControlFlow::map_break()` and `ControlFlow::map_continue()`.
2024-11-30Add diagnostic item for `std::ops::ControlFlow`Samuel Tardieu-0/+1
This will be used in Clippy to detect useless conversions done through `ControlFlow::map_break()` and `ControlFlow::map_continue()`.
2024-11-30Auto merge of #133659 - jieyouxu:rollup-576gh4p, r=jieyouxubors-595/+949
Rollup of 6 pull requests Successful merges: - #131551 (Support input/output in vector registers of PowerPC inline assembly) - #132515 (Fix and undeprecate home_dir()) - #132721 (CI: split x86_64-mingw job) - #133106 (changes old intrinsic declaration to new declaration) - #133496 (thread::available_parallelism for wasm32-wasip1-threads) - #133548 (Add `BTreeSet` entry APIs to match `HashSet`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Stabilize `ptr::fn_addr_eq`Urgau-3/+1
2024-11-30get rid of a bunch of unnecessary rustc_const_unstableRalf Jung-13/+1
2024-11-30Fix chaining `carrying_add`sScott McMurray-1/+1
Something about the MIR lowering for `||` ended up breaking this, but it's fixed by changing the code to use `|` instead. I also added an assembly test to ensure it *keeps* being `adc`.
2024-11-30remove a whole bunch of unnecessary const feature gatesRalf Jung-19/+0
2024-11-30move swap_nonoverlapping constness to separate feature gateRalf Jung-2/+2
2024-11-30move slice::swap_unchecked constness to slice_swap_unchecked feature gateRalf Jung-1/+1
2024-11-30Rollup merge of #133106 - BLANKatGITHUB:intrinsic, r=RalfJung许杰友 Jieyou Xu (Joe)-595/+949
changes old intrinsic declaration to new declaration This pr is for issue #132735 It changes old `extern "intrinsic"` code block with new declaration. There are other blocks that use old declaration but as the changes needed in single block is quite large I do them in parts
2024-11-30Rollup merge of #133625 - RalfJung:custom-mir-debug-info, r=compiler-errors许杰友 Jieyou Xu (Joe)-0/+33
custom MIR: add doc comment for debuginfo This is a revival of https://github.com/rust-lang/rust/pull/117015
2024-11-29Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrumbors-373/+160
Bump boostrap compiler to new beta Currently failing due to something about the const stability checks and `panic!`. I'm not sure why though since I wasn't able to see any PRs merged in the past few days that would result in a `cfg(bootstrap)` that shouldn't be removed. cc `@RalfJung` #131349
2024-11-29refine mir debuginfo docsRalf Jung-5/+14
2024-11-29Doc comment custom MIR debuginfo.Camille GILLOT-0/+24
and add a test for the constant case
2024-11-29Rollup merge of #133530 - timvisee:master, r=jhprattMatthias Krüger-42/+42
Use consistent wording in docs, use is zero instead of is 0 In documentation, wording of _"`rhs` is zero"_ and _"`rhs` is 0"_ is intermixed. This is especially visible [here](https://doc.rust-lang.org/std/primitive.usize.html#method.div_ceil). This changes all occurrences to _"`rhs` is zero"_ for better readability.
2024-11-29Rollup merge of #133466 - aksh1618:patch-1, r=thomccMatthias Krüger-3/+3
Fix typos in pin.rs
2024-11-28Change `GetManyMutError` to match T-libs-api decisionChayim Refael Friedman-28/+32
That is, differentiate between out-of-bounds and overlapping indices, and remove the generic parameter `N`. I also exported `GetManyMutError` from `alloc` (and `std`), which was apparently forgotten. Changing the error to carry additional details means LLVM no longer generates separate short-circuiting branches for the checks, instead it generates one branch at the end. I therefore changed the code to use early returns to make LLVM generate jumps. Benchmark results between the approaches are somewhat mixed, but I chose this approach because it is significantly faster with ranges and also faster with `unwrap()`.
2024-11-28Also use zero when referencing to capacity or lengthtimvisee-18/+18
2024-11-28Use consistent wording in docs, use zero instead of 0timvisee-24/+24
2024-11-28Rollup merge of #133512 - bjoernager:slice-as-array, r=AmanieuGuillaume Gomez-16/+75
Add `as_array` and `as_mut_array` conversion methods to slices. Tracking issue: #133508 This PR unstably implements the `as_array` and `as_mut_array` converters to `[T]`, `*const [T]`, and `*mut [T]`.
2024-11-27update cfgsBoxy-302/+89
2024-11-27replace placeholder versionBoxy-77/+77
2024-11-26Rollup merge of #133402 - compiler-errors:drop-and-destruct, r=lcnrMichael Goulet-1/+2
Constify `Drop` and `Destruct` r? `@lcnr` or `@fee1-dead`
2024-11-26Add '<[T]>::as_array', '<[T]>::as_mut_array', '<*const [T]>::as_array', and ↵Gabriel Bjørnager Jensen-16/+75
'<*mut [T]>::as_mut_array' conversion methods;
2024-11-26Rollup merge of #133282 - tgross35:maybe-uninit-debug, r=AmanieuMichael Goulet-1/+5
Shorten the `MaybeUninit` `Debug` implementation Currently the `Debug` implementation for `MaybeUninit` winds up being pretty verbose. This struct: ```rust #[derive(Debug)] pub struct Foo { pub a: u32, pub b: &'static str, pub c: MaybeUninit<u32>, pub d: MaybeUninit<String>, } ``` Prints as: Foo { a: 0, b: "hello", c: core::mem::maybe_uninit::MaybeUninit<u32>, d: core::mem::maybe_uninit::MaybeUninit<alloc::string::String>, } The goal is just to be a standin for content so the path prefix doesn't add any useful information. Change the implementation to trim `MaybeUninit`'s leading path, meaning the new result is now: Foo { a: 0, b: "hello", c: MaybeUninit<u32>, d: MaybeUninit<alloc::string::String>, }
2024-11-26Rollup merge of #133136 - ChayimFriedman2:get-many-mut, r=AmanieuMichael Goulet-18/+180
Support ranges in `<[T]>::get_many_mut()` As per T-libs-api decision in #104642. I implemented that with a separate trait and not within `SliceIndex`, because doing that via `SliceIndex` requires adding support for range types that are (almost) always overlapping e.g. `RangeFrom`, and also adding fake support code for `impl SliceIndex<str>`. An inconvenience that I ran into was that slice indexing takes the index by value, but I only have it by reference. I could change slice indexing to take by ref, but this is pretty much the hottest code ever so I'm afraid to touch it. Instead I added a requirement for `Clone` (which all index types implement anyway) and cloned. This is an internal requirement the user won't see and the clone should always be optimized away. I also implemented `Clone`, `PartialEq` and `Eq` for the error type, since I noticed it does not do that when writing the tests and other errors in std seem to implement them. I didn't implement `Copy` because maybe we will want to put something non-`Copy` there.
2024-11-25Fix typos in pin.rsAakarshit Uppal-3/+3
2024-11-25Constify Drop and DestructMichael Goulet-1/+2
2024-11-25Auto merge of #133247 - GuillaumeGomez:reduce-integer-display-impl, ↵bors-48/+32
r=workingjubilee Reduce integer `Display` implementation size I was thinking about #128204 and how we could reduce the size of the code and just realized that we didn't need the `_fmt` method to be implemented on signed integers, which in turns allow to simplify greatly the macro call. r? `@workingjubilee`
2024-11-25Support ranges in `<[T]>::get_many_mut()`Chayim Refael Friedman-18/+180
I implemented that with a separate trait and not within `SliceIndex`, because doing that via `SliceIndex` requires adding support for range types that are (almost) always overlapping e.g. `RangeFrom`, and also adding fake support code for `impl SliceIndex<str>`. An inconvenience that I ran into was that slice indexing takes the index by value, but I only have it by reference. I could change slice indexing to take by ref, but this is pretty much the hottest code ever so I'm afraid to touch it. Instead I added a requirement for `Clone` (which all index types implement anyway) and cloned. This is an internal requirement the user won't see and the clone should always be optimized away. I also implemented `Clone`, `PartialEq` and `Eq` for the error type, since I noticed it does not do that when writing the tests and other errors in std seem to implement them. I didn't implement `Copy` because maybe we will want to put something non-`Copy` there.
2024-11-25Rollup merge of #132533 - SUPERCILEX:patch-4, r=Mark-SimulacrumMatthias Krüger-0/+20
Add BorrowedBuf::into_filled{,_mut} methods to allow returning buffer with original lifetime See https://github.com/rust-lang/libs-team/issues/473 and tracking issue https://github.com/rust-lang/rust/issues/117693.
2024-11-25Rollup merge of #133260 - compiler-errors:deref, r=fee1-dead许杰友 Jieyou Xu (Joe)-0/+47
Constify the `Deref`/`DerefMut` traits, too One more constification. Rebased on that one commit that makes it so we don't need to provide stability on const impls. r? fee1-dead
2024-11-24Rollup merge of #133389 - eduardosm:stabilize-const_float_methods, r=RalfJungMatthias Krüger-49/+70
Stabilize `const_float_methods` Tracking issue: https://github.com/rust-lang/rust/issues/130843 Relnotes: #133383 Stabilized const API: ```rust // in `core` impl f32/f64 { pub const fn recip(self) -> Self; pub const fn to_degrees(self) -> Self; pub const fn to_radians(self) -> Self; pub const fn max(self, other: Self) -> Self; pub const fn min(self, other: Self) -> Self; pub const fn clamp(self, min: Self, max: Self) -> Self; pub const fn abs(self) -> Self; pub const fn signum(self) -> Self; pub const fn copysign(self, sign: Self) -> Self; } ``` Closes https://github.com/rust-lang/rust/issues/130843 r? libs-api cc `@RalfJung` -- I think the way const-stability attributes work have change a bit since the last time a wrote a const-stabilization PR, please make sure I got them right.
2024-11-24Rollup merge of #133301 - GuillaumeGomez:add-example-wrapping-neg, ↵Matthias Krüger-0/+1
r=workingjubilee Add code example for `wrapping_neg` method for signed integers With this example, we make it obvious that `wrapping_neg` works both ways (neg to pos and pos to neg). r? `@workingjubilee`
2024-11-24changes old intrinsic declaration to new declarationaaishwarymishra@gmail.com-595/+949
blesses tests/ui/intrinsics blesses tests/ui/intrinsics
2024-11-24Constify Deref and DerefMutMichael Goulet-0/+47
2024-11-23Match simd_relaxed_fma documentation to fmuladd intrinsicCaleb Zulawski-4/+8
2024-11-23Auto merge of #133379 - jieyouxu:rollup-00jxo71, r=jieyouxubors-0/+14
Rollup of 4 pull requests Successful merges: - #133217 ([AIX] Add option -X32_64 to the "strip" command) - #133237 (Minimally constify `Add`) - #133355 (Add language tests for aggregate types) - #133374 (show abi_unsupported_vector_types lint in future breakage reports) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-23Add simd_relaxed_fma intrinsicCaleb Zulawski-0/+10
2024-11-23Stabilize `const_float_methods`Eduardo Sánchez Muñoz-49/+70
2024-11-23Improve code by using `unsigned_abs`Guillaume Gomez-18/+2
2024-11-23Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors许杰友 Jieyou Xu (Joe)-0/+14
Minimally constify `Add` * This PR removes the requirement for `impl const` to have a const stability attribute. cc ``@RalfJung`` I believe you mentioned that it would make much more sense to require `const_trait`s to have const stability instead. I agree with that sentiment but I don't think that is _required_ for a small scale experimentation like this PR. https://github.com/rust-lang/project-const-traits/issues/16 should definitely be prioritized in the future, but removing the impl check should be good for now as all callers need `const_trait_impl` enabled for any const impl to work. * This PR is intentionally minimal as constifying other traits can become more complicated (`PartialEq`, for example, would run into requiring implementing it for `str` as that is used in matches, which runs into the implementation for slice equality which uses specialization) Per the reasons above, anyone who is interested in making traits `const` in the standard library are **strongly encouraged** to reach out to us on the [Zulip channel](https://rust-lang.zulipchat.com/#narrow/channel/419616-t-compiler.2Fproject-const-traits) before proceeding with the work. cc ``@rust-lang/project-const-traits`` I believe there is prior approval from libs that we can experiment, so r? project-const-traits