about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-10-12library: Stabilize `const_replace`Jubilee Young-3/+4
Depends on stabilizing `const_ptr_write`. Const-stabilizes: - `core::mem::replace` - `core::ptr::replace`
2024-10-12library: Stabilize `const_ptr_write`Jubilee Young-12/+12
Const-stabilizes: - `write` - `write_bytes` - `write_unaligned` In the following paths: - `core::ptr` - `core::ptr::NonNull` - pointer `<*mut T>` Const-stabilizes the internal `core::intrinsics`: - `write_bytes` - `write_via_move`
2024-10-12library: Stabilize `const_intrinsic_forget`Jubilee Young-2/+1
This is an implicit requirement of stabilizing `const_ptr_write`. Const-stabilizes the internal `core::intrinsics`: - `forget`
2024-10-11Rollup merge of #131289 - RalfJung:duration_consts_float, r=tgross35Trevor Gross-7/+6
stabilize duration_consts_float Waiting for FCP in https://github.com/rust-lang/rust/issues/72440 to pass. `as_millis_f32` and `as_millis_f64` are not stable at all yet, so I moved their const-stability together with their regular stability (tracked at https://github.com/rust-lang/rust/issues/122451). Fixes https://github.com/rust-lang/rust/issues/72440
2024-10-11Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlinTrevor Gross-0/+53
intrinsics fmuladdf{32,64}: expose llvm.fmuladd.* semantics Add intrinsics `fmuladd{f32,f64}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc). --- This topic has been discussed a few times on Zulip and was suggested, for example, by `@workingjubilee` in [Effect of fma disabled](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Effect.20of.20fma.20disabled/near/274179331).
2024-10-11Avoid superfluous UB checks in `IndexRange`Josh Stone-4/+7
`IndexRange::len` is justified as an overall invariant, and `take_prefix` and `take_suffix` are justified by local branch conditions. A few more UB-checked calls remain in cases that are only supported locally by `debug_assert!`, which won't do anything in distributed builds, so those UB checks may still be useful. We generally expect core's `#![rustc_preserve_ub_checks]` to optimize away in user's release builds, but the mere presence of that extra code can sometimes inhibit optimization, as seen in #131563.
2024-10-11Rollup merge of #131463 - bjoernager:const-char-encode-utf8, r=RalfJungTrevor Gross-3/+5
Stabilise `const_char_encode_utf8`. Closes: #130512 This PR stabilises the `const_char_encode_utf8` feature gate (i.e. support for `char::encode_utf8` in const scenarios). Note that the linked tracking issue is currently awaiting FCP.
2024-10-11Rollup merge of #131287 - RalfJung:const_result, r=tgross35Trevor Gross-4/+9
stabilize const_result Waiting for FCP to complete in https://github.com/rust-lang/rust/issues/82814 Fixes #82814
2024-10-11Rollup merge of #131109 - tgross35:stabilize-debug_more_non_exhaustive, r=joboetTrevor Gross-12/+4
Stabilize `debug_more_non_exhaustive` Fixes: https://github.com/rust-lang/rust/issues/127942
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-0/+53
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
2024-10-11Single commit implementing the enzyme/autodiff frontendManuel Drehwald-0/+27
Co-authored-by: Lorenz Schmidt <bytesnake@mailbox.org>
2024-10-11stabilize const_resultRalf Jung-4/+9
2024-10-11stabilize duration_consts_floatRalf Jung-7/+6
2024-10-11Rollup merge of #131512 - j7nw4r:master, r=jhprattMatthias Krüger-1/+2
Fixing rustDoc for LayoutError. I started reading the the std lib from start to finish and noticed that this rustdoc comment wasn't correct.
2024-10-11rename RcBox in other places tooJonathan Dönszelmann-7/+7
2024-10-10Fixing rustDoc for LayoutError.Johnathan W-1/+2
2024-10-10Rollup merge of #130538 - ultrabear:ultrabear_const_from_ref, r=workingjubileeMatthias Krüger-4/+4
Stabilize const `{slice,array}::from_mut` This PR stabilizes the following APIs as const stable as of rust `1.83`: ```rs // core::array pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1]; // core::slice pub const fn from_mut<T>(s: &mut T) -> &mut [T]; ``` This is made possible by `const_mut_refs` being stabilized (yay). Tracking issue: #90206
2024-10-10Stabilise 'const_char_encode_utf8';Gabriel Bjørnager Jensen-3/+5
2024-10-09Clean up is_aligned_and_not_nullBen Kimock-3/+3
2024-10-09Add more precondition check testsBen Kimock-3/+5
2024-10-09Allow zero-size reads/writes on null pointersBen Kimock-19/+29
2024-10-09Optimize escape_asciiltdk-23/+91
2024-10-09Rollup merge of #131383 - ↵Matthias Krüger-0/+21
AngelicosPhosphoros:better_doc_for_slice_slicing_at_ends, r=cuviper Add docs about slicing slices at the ends Closes https://github.com/rust-lang/rust/issues/60783
2024-10-09Rollup merge of #130827 - fmease:library-mv-obj-save-dyn-compat, r=ibraheemdevMatthias Krüger-18/+22
Library: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
2024-10-09Add "not guaranteed to be equal"Kevin Reid-1/+1
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-10-09Apply suggestions from code reviewKevin Reid-2/+4
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-10-09Expand `ptr::fn_addr_eq()` documentation.Kevin Reid-6/+32
* Describe more clearly what is (not) guaranteed, and de-emphasize the implementation details. * Explain what you *can* reliably use it for.
2024-10-09Library: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-18/+22
2024-10-09stabilize `{slice,array}::from_mut`ultrabear-4/+4
2024-10-08Stabilize Pin::as_deref_mutNoa-1/+1
2024-10-08Stabilize `isqrt` featureChai T. Rex-13/+8
2024-10-08Add LowerExp and UpperExp implementationsrickdewater-16/+30
Mark the new fmt impls with the correct rust version Clean up the fmt macro and format the tests
2024-10-08Add docs about slicing slices at the endsAngelicosPhosphoros-0/+21
Closes https://github.com/rust-lang/rust/issues/60783
2024-10-07cfg out checks in add and sub but not offsetBen Kimock-0/+8
...because the checks in offset found bugs in a crater run.
2024-10-07Add precondition checks to ptr::offset, ptr::add, ptr::subBen Kimock-3/+173
2024-10-06Expand set_ptr_value / with_metadata_of docsAndreas Molzer-20/+61
Rewrite these blobs to explicitly mention the case of a sized operand. The previous made that seem wrong instead of emphasizing it is nothing but a simple cast. Instead, the explanation now emphasizes that the address portion of the argument, together with its provenance, is discarded which previously had to be inferred by the reader. Then an example demonstrates a simple line of incorrect usage based on this idea of provenance.
2024-10-06grammar fixdacian-1/+1
2024-10-06Rollup merge of #131316 - programmerjake:patch-4, r=NoratriebMatthias Krüger-1/+1
Fix typo in primitive_docs.rs typo introduced in #129559
2024-10-05Fix typo in primitive_docs.rsJacob Lifshay-1/+1
2024-10-06Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebankbors-0/+1
Add a Lint for Pointer to Integer Transmutes in Consts Fixes #87525 This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments. Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680: > ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though. References: 1. https://doc.rust-lang.org/std/mem/fn.transmute.html 2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-05Rollup merge of #131281 - RalfJung:const-cell, r=AmanieuMatthias Krüger-6/+12
make Cell unstably const Now that we can do interior mutability in `const`, most of the Cell API can be `const fn`. :) The main exception is `set`, because it drops the old value. So from const context one has to use `replace`, which delegates the responsibility for dropping to the caller. Tracking issue: https://github.com/rust-lang/rust/issues/131283 `as_array_of_cells` is itself still unstable to I added the const-ness to the feature gate for that function and not to `const_cell`, Cc #88248. r? libs-api
2024-10-05library: Stabilize const `MaybeUninit::assume_init_mut`Jubilee Young-3/+7
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-10-05Add a Lint for Pointer to Integer Transmutes in ConstsVeera-0/+1
2024-10-05Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdevMatthias Krüger-18/+16
move f16/f128 const fn under f16/f128 feature gate The `*_const` features were added to work around https://github.com/rust-lang/rust/issues/129656, which should not be needed any more.
2024-10-05make Cell unstably constRalf Jung-6/+12
2024-10-05move f16/f128 const fn under f16/f128 feature gateRalf Jung-18/+16
2024-10-05Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`onestacked-8/+14
2024-10-04Rollup merge of #130403 - ↵Jubilee-4/+7
eduardosm:stabilize-const_slice_from_raw_parts_mut, r=workingjubilee Stabilize `const_slice_from_raw_parts_mut` Stabilizes https://github.com/rust-lang/rust/issues/67456, since https://github.com/rust-lang/rust/issues/57349 has been stabilized. Stabilized const API: ```rust // core::ptr pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T]; // core::slice pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T]; // core::ptr::NonNull pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self ``` Closes https://github.com/rust-lang/rust/issues/67456. r? libs-api
2024-10-04Rollup merge of #131177 - workingjubilee:stabilize-const-mut-referees, ↵Jubilee-13/+21
r=tgross35 Stabilize 5 `const_mut_refs`-dependent API Since `const_mut_refs` and `const_refs_to_cell` have been stabilized, we now may create mutable references inside our library API. Thus we now stabilize the `const fn` version of these public library APIs which required such in their implementation: - const `NonNull::as_mut` https://github.com/rust-lang/rust/issues/91822#issuecomment-2338930442 - const `slice::{first,last}_mut`: https://github.com/rust-lang/rust/issues/83570#issuecomment-2334847112 - const `str::as_{mut_ptr,bytes_mut}`: https://github.com/rust-lang/rust/issues/130086#issuecomment-2336408562 - const `str::from_utf8_unchecked_mut`: https://github.com/rust-lang/rust/issues/91005#issuecomment-2359820672 - const `UnsafeCell::get_mut`: https://github.com/rust-lang/rust/issues/88836#issuecomment-2359817772
2024-10-04Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnayJubilee-15/+7
Stabilize the `map`/`value` methods on `ControlFlow` And fix the stability attribute on the `pub use` in `core::ops`. libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP. Summary: ```rust impl<B, C> ControlFlow<B, C> { pub fn break_value(self) -> Option<B>; pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>; pub fn continue_value(self) -> Option<C>; pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>; } ``` Resolves #75744 ``@rustbot`` label +needs-fcp +t-libs-api -t-libs --- Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.