about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-07-24Rollup merge of #144278 - Qelxiros:rev-into-inner, r=tgross35León Orell Valerian Liehr-0/+19
add Rev::into_inner Tracking issue: rust-lang/rust#144277
2025-07-23add Rev::into_innerJeremy Smart-0/+19
2025-07-23Document (internally) that `Range*<&T> as RangeBounds<T>` impls are ↵Zachary S-0/+48
intentionally not `T: ?Sized`, and document (publically) an alternative.
2025-07-23Disable non_exhaustive_omitted_patterns within matches! macroJonas Platte-0/+2
2025-07-23Hint that choose_pivot returns index in boundsKornel-10/+10
2025-07-23atomicrmw on pointers: move integer-pointer cast hacks into backendRalf Jung-62/+57
2025-07-23add links to collectionsgewitternacht-0/+5
2025-07-23remove trailing whitespacegewitternacht-1/+1
2025-07-22document assumptions about `Clone` and `Eq` traitsgewitternacht-0/+24
2025-07-22Auto merge of #144205 - hkBst:flt2dec, r=workingjubileebors-11/+7
flt2dec: replace for loop by iter_mut Perf is explored in https://github.com/rust-lang/rust/issues/144118, which initially showed small losses, but then also showed significant gains. Both are real, but given the smallness of the losses, this seems a good change.
2025-07-22Rollup merge of #144212 - bjorn3:remove_unique_lang_item, r=oli-obk许杰友 Jieyou Xu (Joe)-2/+0
Remove the ptr_unique lang item Miri no longer uses it since https://github.com/rust-lang/miri/pull/4307.
2025-07-22Rollup merge of #143768 - Randl:const-try, r=oli-obk许杰友 Jieyou Xu (Joe)-69/+149
Constify Try, From, TryFrom and relevant traits
2025-07-21Constify Try, From, TryFromEvgenii Zheltonozhskii-69/+149
2025-07-21Stabilize const `TypeId::of`Oli Scherer-2/+2
2025-07-20Option::as_slice: fix commentRalf Jung-1/+1
2025-07-20flt2dec: use fill instead of loopMarijn Schouten-11/+7
2025-07-20Rollup merge of #143423 - hkBst:clippy-fix-1, r=workingjubileeGuillaume Gomez-32/+28
address clippy formatting nits - int_log10.rs: change top level doc comments to outer - collect.rs: remove empty line after doc comment - clippy fix: markdown indentation for indented items after line break: a markdown list item continued over multiples lines, but those following lines which are part of the same item are not indented - clippy fix: bound in one place: when there is a bound in angle brackets and another bound on the same variable in a where clause
2025-07-20Rollup merge of #143282 - nxsaken:strict_sub_signed, r=jhprattGuillaume Gomez-4/+41
Add `uX::strict_sub_signed` rust-lang/rust#116090 missed `strict_sub_signed`, adding it here. Part of rust-lang/rust#118260. r? ``@m-ou-se``
2025-07-20Remove the ptr_unique lang itembjorn3-2/+0
Miri no longer uses it.
2025-07-20Rollup merge of #144169 - RalfJung:type-id-fix, r=oli-obkMatthias Krüger-1/+1
interpret: fix TypeId pointers being considered data pointers Fixes https://github.com/rust-lang/miri/issues/4477 r? ````@oli-obk````
2025-07-20Rollup merge of #144111 - clarfonthey:maybe-uninit-deprecated, r=jhprattMatthias Krüger-112/+2
Remove deprecated `MaybeUninit` slice methods These were left in to make migration a bit easier, although they should be removed now since they were never stable.
2025-07-20Rollup merge of #143604 - nxsaken:const_float_round_methods, r=RalfJungMatthias Krüger-24/+20
Stabilize `const_float_round_methods` Closes rust-lang/rust#141555, waiting for FCP.
2025-07-20Rollup merge of #141260 - LuigiPiucco:volatile-null, r=RalfJungMatthias Krüger-78/+108
Allow volatile access to non-Rust memory, including address 0 This PR relaxes the `ub_check` in the `read_volatile`/`write_volatile` pointer operations to allow passing null. This is needed to support processors which hard-code peripheral registers on address 0, like the AVR chip ATtiny1626. LLVM understands this as valid and handles it correctly, as tested in my [PR to add a note about it](https://github.com/llvm/llvm-project/pull/139803/commits/6387c82255c56d3035d249eb54110695e76b8030#diff-81bbb96298c32fa901beb82ab3b97add27a410c01d577c1f8c01000ed2055826) (rustc generates the same LLVM IR as expected there when this PR is applied, and consequently the same AVR assembly). Follow-up and implementation of the discussions in: - https://internals.rust-lang.org/t/pre-rfc-conditionally-supported-volatile-access-to-address-0/12881/7 - https://github.com/Rahix/avr-device/pull/185; - [#t-lang > Adding the possibility of volatile access to address 0](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Adding.20the.20possibility.20of.20volatile.20access.20to.20address.200/with/513303502) - https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303 r? ````@RalfJung```` Also fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/29 (about as good as it'll get, null will likely never be a "normal" address in Rust)
2025-07-19Remove deprecated MaybeUninit slice methodsltdk-112/+2
2025-07-20Add `#[rustc_intrinsic_const_stable_indirect]` to float roundingNurzhan Sakén-0/+20
intrinsics
2025-07-20Stabilize `const_float_round_methods`Nurzhan Sakén-24/+0
2025-07-19update `Atomic*::from_ptr` and `Atomic*::as_ptr` docsusamoi-9/+15
2025-07-19Auto merge of #144166 - matthiaskrgr:rollup-wccepuo, r=matthiaskrgrbors-41/+33
Rollup of 10 pull requests Successful merges: - rust-lang/rust#141076 (fix Zip unsoundness (again)) - rust-lang/rust#142444 (adding run-make test to autodiff) - rust-lang/rust#143704 (Be a bit more careful around exotic cycles in in the inliner) - rust-lang/rust#144073 (Don't test panic=unwind in panic_main.rs on Fuchsia) - rust-lang/rust#144083 (miri sleep tests: increase slack) - rust-lang/rust#144092 (bootstrap: Detect musl hosts) - rust-lang/rust#144098 (Do not lint private-in-public for RPITIT) - rust-lang/rust#144103 (Rename `emit_unless` to `emit_unless_delay`) - rust-lang/rust#144108 (Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling) - rust-lang/rust#144115 (fix outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-19interpret: fix TypeId pointers being considered data pointersRalf Jung-1/+1
2025-07-19Rollup merge of #141076 - the8472:fix-zip-panic-safety2, r=workingjubileeMatthias Krüger-41/+33
fix Zip unsoundness (again) Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. #82292 tried to fix unsoundness (#82291) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (#86443), but the fix #86452 didn't fix it for nested Zip iterators (#137255). Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in #83791 but we haven't made use of that so far. fixes #137255
2025-07-18clippy fix: bound in one placeMarijn Schouten-6/+7
2025-07-18Rollup merge of #143382 - fee1-dead-contrib:push-trrymlzqmmoz, r=jhprattMatthias Krüger-1/+2
stabilize `const_slice_reverse` cc rust-lang/rust#135120, needs FCP.
2025-07-18fix: don't panic on volatile access to nullLuigi Sartor Piucco-78/+108
According to https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303/4, LLVM allows volatile operations on null and handles it correctly. This should be allowed in Rust as well, because I/O memory may be hard-coded to address 0 in some cases, like the AVR chip ATtiny1626. A test case that ensured a failure when passing null to volatile was removed, since it's now valid. Due to the addition of `maybe_is_aligned` to `ub_checks`, `maybe_is_aligned_and_not_null` was refactored to use it. docs: revise restrictions on volatile operations A distinction between usage on Rust memory vs. non-Rust memory was introduced. Documentation was reworded to explain what that means, and make explicit that: - No trapping can occur from volatile operations; - On Rust memory, all safety rules must be respected; - On Rust memory, the primary difference from regular access is that volatile always involves a memory dereference; - On Rust memory, the only data affected by an operation is the one pointed to in the argument(s) of the function; - On Rust memory, provenance follows the same rules as non-volatile access; - On non-Rust memory, any address known to not contain Rust memory is valid (including 0 and usize::MAX); - On non-Rust memory, no Rust memory may be affected (it is implicit that any other non-Rust memory may be affected, though, even if not referenced by the pointer). This should be relevant when, for example, reading register A causes a flag to change in register B, or writing to A causes B to change in some way. Everything affected mustn't be inside an allocation. - On non-Rust memory, provenance is irrelevant and a pointer with none can be used in a valid way. fix: don't lint null as UB for volatile Also remove a now-unneeded `allow` line. fix: additional wording nits
2025-07-18Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-deadMatthias Krüger-16/+35
Make slice comparisons const This needed a fix for `derive_const`, too, as it wasn't usable in libcore anymore as trait impls need const stability attributes. I think we can't use the same system as normal trait impls while `const_trait_impl` is still unstable. r? ```@fee1-dead``` cc rust-lang/rust#143800
2025-07-18Rollup merge of #143967 - oli-obk:const-option-methods, r=fee1-deadMatthias Krüger-40/+97
constify `Option` methods r? ```````@fee1-dead``````` tracking issue: rust-lang/rust#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
2025-07-17Make slices `[const] PartialEq`Oli Scherer-11/+28
2025-07-17Make `derive_const` usable within libcore againOli Scherer-2/+2
Also make it *only* usable on nightly
2025-07-17Make `NonZero` `const PartialEq`Oli Scherer-2/+3
2025-07-17Make `Option` `const PartialEq`Oli Scherer-1/+2
2025-07-17constify `Option` methodsOli Scherer-40/+97
2025-07-17Rollup merge of #143326 - hkBst:rm-deprecated-1, r=jhprattMatthias Krüger-17/+9
Remove deprecated `Error::description` impl from `c_str::FromBytesWithNulError`
2025-07-17Stabilize as_array_of_cellsJosh Simmons-2/+2
2025-07-17Rollup merge of #143829 - a1phyr:trim_borrowed_buf, r=ChrisDentonLeón Orell Valerian Liehr-29/+6
Trim `BorrowedCursor` API This PR removes some method from the unstable `BorrowedCursor` type. A rational for each change can be found in the message of each commit. I don't think that an ACP is required for this, please tell me if it is not the case. Cc rust-lang/rust#78485 rust-lang/rust#117693
2025-07-17Rollup merge of #143820 - nazo6:fix-optimize-for-size, r=Mark-SimulacrumLeón Orell Valerian Liehr-4/+5
Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets This fixes rust-lang/rust#143804.
2025-07-17Rollup merge of #143595 - fee1-dead-contrib:push-sylpykzkmynr, ↵León Orell Valerian Liehr-0/+9
r=RalfJung,fee1-dead add `const_make_global`; err for `const_allocate` ptrs if didn't call Implements as discussed on Zulip: [#t-compiler/const-eval > const heap](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const.20heap/with/527125421) r? ```@rust-lang/wg-const-eval``` Fixes https://github.com/rust-lang/rust/issues/129233
2025-07-16Rollup merge of #143921 - oli-obk:const-index, r=fee1-deadSamuel Tardieu-54/+101
Constify `Index` traits tracking issue: rust-lang/rust#143775 the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate. r? ```````@fee1-dead```````
2025-07-16Rollup merge of #143355 - hkBst:cleanup-shift-double-bitmask, r=Mark-SimulacrumSamuel Tardieu-42/+6
wrapping shift: remove first bitmask and table ```rust #[inline(always)] pub const fn wrapping_shl(self, rhs: u32) -> Self { // SAFETY: the masking by the bitsize of the type ensures that we do not shift // out of bounds unsafe { self.unchecked_shl(rhs & (Self::BITS - 1)) } } ``` already does the bitmask, so it seems unnecessary here. More context: internals.rust-lang.org/t/wrapping-shift-operator-code-doing-bitmasking-twice/23167
2025-07-16add `const_make_global`; err for `const_allocate` ptrs if didn't callDeadbeef-0/+9
Co-Authored-By: Ralf Jung <post@ralfj.de> Co-Authored-By: Oli Scherer <github333195615777966@oli-obk.de>
2025-07-15docs: update documentation of core::mem::copy to include const on the fn ↵SunkenPotato-1/+1
signature
2025-07-15Rollup merge of #143941 - folkertdev:cfg-select-docs, r=traviscrossSamuel Tardieu-9/+7
update `cfg_select!` documentation tracking issue: https://github.com/rust-lang/rust/issues/115585 After rust-lang/rust#143461, and with an eye on a soon(ish) stabilization, I think the docs need some work. The existing text read more like a motivation for the feature existing to me, so I've tried to now be a bit more descriptive. Still, suggestions are very welcome. I also added a test for an empty `select! {}` because it's just the sort of thing that might break. r? ``@traviscross``