about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-09-29Remove duplicate sectionLukas Bergdoll-13/+1
2024-09-29Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrumbors-5/+10
Update `catch_unwind` doc comments for `c_unwind` Updates `catch_unwind` doc comments to indicate that catching a foreign exception _will no longer_ be UB. Instead, there are two possible behaviors, though it is not specified which one an implementation will choose. Nominated for t-lang to confirm that they are okay with making such a promise based on t-opsem FCP, or whether they would like to be included in the FCP. Related: https://github.com/rust-lang/rust/issues/74990, https://github.com/rust-lang/rust/issues/115285, https://github.com/rust-lang/reference/pull/1226
2024-09-28Rename `standalone` doctest attribute into `standalone-crate`Guillaume Gomez-1/+1
2024-09-28Further clarificarion for atomic and UnsafeCell docs:Ralf Jung-23/+24
- UnsafeCell: mention the term "data race", and reference the data race definition - atomic: failing RMWs are just reads, reorder and reword docs
2024-09-28allow mixed-size atomic readsRalf Jung-10/+16
2024-09-28atomics: allow atomic and non-atomic reads to raceRalf Jung-24/+38
2024-09-28stabilize const_cell_into_innerRalf Jung-51/+11
2024-09-28make ptr metadata functions callable from stable const fnRalf Jung-29/+7
2024-09-28Update Unicode escapes;Gabriel Bjørnager Jensen-2/+1
2024-09-27Rollup merge of #129087 - slanterns:option_get_or_insert_default, r=dtolnayMatthias Krüger-3/+1
Stabilize `option_get_or_insert_default` Closes: https://github.com/rust-lang/rust/issues/82901. `@rustbot` label: +T-libs-api r? libs-api
2024-09-27Add 'from_ref' and 'from_mut' constructors to 'core::ptr::NonNull';Gabriel Bjørnager Jensen-6/+23
2024-09-27Apply review feedbackLukas Bergdoll-13/+16
2024-09-27Apply round 1 of review commentsLukas Bergdoll-16/+15
2024-09-27Fix mistake in exampleLukas Bergdoll-1/+1
2024-09-27Improve Ord docsLukas Bergdoll-95/+263
- Makes wording more clear and re-structures some sections that can be overwhelming for some not already in the know. - Adds examples of how *not* to implement Ord, inspired by various anti-patterns found in real world code.
2024-09-26Rollup merge of #130875 - folkertdev:naked-asm-bootstrap, r=tgross35Jubilee-0/+34
update `compiler-builtins` to 0.1.126 this requires the addition of a bootstrap variant of the new `naked_asm!` macro r? `@tgross35` extracted from https://github.com/rust-lang/rust/pull/128651
2024-09-26Rollup merge of #130313 - c410-f3r:unlock-rfc-2011, r=thomccJubilee-5/+25
[`cfg_match`] Generalize inputs cc #115585 Changes the input type from `item` to `tt`, which makes the macro have the same functionality of `cfg_if`. Also adds a test to ensure that `stmt_expr_attributes` is not triggered.
2024-09-27Rollup merge of #130880 - RalfJung:const-hack, r=scottmcmGuillaume Gomez-1/+1
add missing FIXME(const-hack) r? ```@scottmcm```
2024-09-27Rollup merge of #130845 - RalfJung:utf8chunk, r=tgross35Guillaume Gomez-0/+4
Utf8Chunks: add link to Utf8Chunk It is currently surprisingly non-trivial to go from the `utf8_chunks` method to the docs of the `valid`/`invalid` methods used in the example. This should help.
2024-09-27Rollup merge of #130279 - theemathas:manually-drop-docs, r=thomcc,traviscrossGuillaume Gomez-12/+118
Document subtleties of `ManuallyDrop` After seeing #130140 and #130141, I figured that `ManuallyDrop` needs documentation explaining its subtleties, hence this PR. See also https://github.com/rust-lang/unsafe-code-guidelines/issues/245
2024-09-26add missing FIXME(const-hack)Ralf Jung-1/+1
2024-09-26Add `[Option<T>; N]::transpose`Urgau-0/+24
2024-09-26add a bootstrap variant of `naked_asm`Folkert de Vries-0/+34
2024-09-25Stabilize the `map`/`value` methods on `ControlFlow`Scott McMurray-15/+7
And fix the stability attribute on the `pub use` in `core::ops`.
2024-09-25Use `&raw` in the standard libraryJosh Stone-13/+10
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-25Rollup merge of #130832 - RalfJung:sort-cfg-mess, r=workingjubileeMatthias Krüger-11/+11
fix some cfg logic around optimize_for_size and 16-bit targets Fixes https://github.com/rust-lang/rust/issues/130818. Fixes https://github.com/rust-lang/rust/issues/129910. There are still some warnings when building on a 16bit target: ``` warning: struct `AlignedStorage` is never constructed --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:135:8 | 135 | struct AlignedStorage<T, const N: usize> { | ^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated items `new` and `as_uninit_slice_mut` are never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:141:8 | 140 | impl<T, const N: usize> AlignedStorage<T, N> { | -------------------------------------------- associated items in this implementation 141 | fn new() -> Self { | ^^^ ... 145 | fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] { | ^^^^^^^^^^^^^^^^^^^ warning: function `quicksort` is never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/unstable/quicksort.rs:19:15 | 19 | pub(crate) fn quicksort<'a, T, F>( | ^^^^^^^^^ warning: `core` (lib) generated 3 warnings ``` However, the cfg stuff here is sufficiently messy that I didn't want to touch more of it. I think all `feature = "optimize_for_size"` should become `any(feature = "optimize_for_size", target_pointer_width = "16")` but I am not entirely certain. Warnings are fine, Miri will just ignore them. Cc `@Voultapher`
2024-09-25Utf8Chunks: add link to Utf8ChunkRalf Jung-0/+4
2024-09-25fix some cfg logic around optimize_for_size and 16-bit targetsRalf Jung-11/+11
2024-09-25Add 'must_use' attribute to 'char::len_utf8' and 'char::len_utf16';Gabriel Bjørnager Jensen-0/+4
2024-09-24Auto merge of #129587 - Voultapher:opt-for-size-variants-of-sort-impls, ↵bors-59/+202
r=cuviper Add `optimize_for_size` variants for stable and unstable sort as well as select_nth_unstable - Stable sort uses a simple merge-sort that re-uses the existing - rather gnarly - merge function. - Unstable sort jumps directly to the branchless heapsort fallback. - select_nth_unstable jumps directly to the median_of_medians fallback, which is augmented with a custom tiny smallsort and partition impl. Some code is duplicated but de-duplication would bring it's own problems. For example `swap_if_less` is critical for performance, if the sorting networks don't inline it perf drops drastically, however `#[inline(always)]` is also a poor fit, if the provided comparison function is huge, it gives the compiler an out to only instantiate `swap_if_less` once and call it. Another aspect that would suffer when making `swap_if_less` pub, is having to cfg out dozens of functions in in smallsort module. Part of https://github.com/rust-lang/rust/issues/125612 r​? `@Kobzol`
2024-09-24Auto merge of #130738 - bjoernager:const-make-ascii, r=jhprattbors-6/+20
Mark `make_ascii_uppercase` and `make_ascii_lowercase` in `[u8]` and `str` as const. Relevant tracking issue: #130698 This PR extends #130697 and #130713 to the similar methods in byte slices (`[u8]`) and string slices (`str`). For the `str` methods, this simply requires adding the `const` specifier to the function signatures. The `[u8]` methods, however, require (at least a temporary) reimplementation due to the use of iterators and `for` loops.
2024-09-24Mark and implement 'make_ascii_uppercase' and 'make_ascii_lowercase' in ↵Gabriel Bjørnager Jensen-6/+20
'[u8]' and 'str' as const;
2024-09-23Rollup merge of #130762 - RalfJung:const_intrinsic_copy, r=dtolnayMichael Goulet-21/+15
stabilize const_intrinsic_copy Fixes https://github.com/rust-lang/rust/issues/80697 This stabilizes ```rust mod ptr { pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize); } impl *const T { pub const unsafe fn copy_to(self, dest: *mut T, count: usize); pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize); } impl *mut T { pub const unsafe fn copy_to(self, dest: *mut T, count: usize); pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize); pub const unsafe fn copy_from(self, src: *const T, count: usize); pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize); } impl <T> NonNull<T> { pub const unsafe fn copy_to(self, dest: NonNull<T>, count: usize); pub const unsafe fn copy_to_nonoverlapping(self, dest: NonNull<T>, count: usize); pub const unsafe fn copy_from(self, src: NonNull<T>, count: usize); pub const unsafe fn copy_from_nonoverlapping(self, src: NonNull<T>, count: usize); } ``` In particular, this reverts https://github.com/rust-lang/rust/pull/117905, which reverted https://github.com/rust-lang/rust/pull/97276. The `NonNull` methods are not listed in the tracking issue, they were added to this feature gate in https://github.com/rust-lang/rust/pull/124498. The existing [FCP](https://github.com/rust-lang/rust/issues/80697#issuecomment-1022585839) does not cover them. They are however entirely identical to the `*mut` methods and already stable outside `const`. ``@rust-lang/libs-api`` please let me know if FCP will be required for the `NonNull` methods.
2024-09-23stabilize const_intrinsic_copyRalf Jung-21/+15
2024-09-23Add fast path for ascii to ascii in str::replaceLaiho-0/+33
2024-09-23random: add tracking issue, address other commentsjoboet-3/+3
2024-09-23std: implement the `random` featurejoboet-0/+64
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-09-23Rollup merge of #130713 - bjoernager:const-char-make-ascii, r=NoratriebMatthias Krüger-4/+6
Mark `u8::make_ascii_uppercase` and `u8::make_ascii_lowercase` as const. Relevant tracking issue: #130698 This PR extends #130697 by also marking the `make_ascii_uppercase` and `make_ascii_lowercase` methods in `u8` as const. The `const_char_make_ascii` feature gate is additionally renamed to `const_make_ascii`.
2024-09-23Rollup merge of #130659 - bjoernager:const-char-encode-utf16, r=dtolnayMatthias Krüger-25/+36
Support `char::encode_utf16` in const scenarios. Relevant tracking issue: #130660 The method `char::encode_utf16` should be marked "const" to allow compile-time conversions. This PR additionally rewrites the `encode_utf16_raw` function for better readability whilst also reducing the amount of unsafe code. try-job: x86_64-msvc
2024-09-23Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnayMatthias Krüger-0/+11
Add str.as_str() for easy Deref to string slices Working with `Box<str>` is cumbersome, because in places like `iter.filter()` it can end up being `&Box<str>` or even `&&Box<str>`, and such type doesn't always get auto-dereferenced as expected. Dereferencing such box to `&str` requires ugly syntax like `&**boxed_str` or `&***boxed_str`, with the exact amount of `*`s. `Box<str>` is [not easily comparable with other string types](https://github.com/rust-lang/rust/pull/129852) via `PartialEq`. `Box<str>` won't work for lookups in types like `HashSet<String>`, because `Borrow<String>` won't take types like `&Box<str>`. OTOH `set.contains(s.as_str())` works nicely regardless of levels of indirection. `String` has a simple solution for this: the `as_str()` method, and `Box<str>` should too.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-118/+126
2024-09-22Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'u8' as const; ↵Gabriel Bjørnager Jensen-4/+6
Rename 'const_char_make_ascii' feature gate to 'const_make_ascii';
2024-09-22Rollup merge of #130692 - RalfJung:result-flatten, r=NoratriebGuillaume Gomez-2/+8
make unstable Result::flatten a const fn This method is still unstable (tracked at https://github.com/rust-lang/rust/issues/70142), but there's no reason I can see for it not to be const -- after all, `Option::flatten` is const. So let's make the `Result` one `const` as well, under the same feature gate. Cc https://github.com/rust-lang/rust/issues/70142
2024-09-22Rollup merge of #130658 - EqualMa:patch-1, r=scottmcmGuillaume Gomez-1/+1
Fix docs of compare_bytes The docs of `compare_bytes`. The return value is positive if <del>`right`</del> `left` is greater
2024-09-22Auto merge of #130697 - bjoernager:const-char-make-ascii, r=dtolnaybors-2/+4
Mark `char::make_ascii_uppercase` and `char::make_ascii_lowercase` as const. Relevant tracking issue: #130698 The `make_ascii_uppercase` and `make_ascii_lowercase` methods in `char` should be marked "const." With the stabilisation of [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349/), this simply requires adding the `const` specifier to the function signatures.
2024-09-22Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'char' as const;Gabriel Bjørnager Jensen-2/+4
2024-09-22make unstable Result::flatten a const fnRalf Jung-2/+8
2024-09-21Mark and implement 'char::encode_utf16' as const; Rewrite 'encode_utf16_raw';Gabriel Bjørnager Jensen-25/+36
2024-09-21Fix docs of compare_bytesEqualMa-1/+1
2024-09-21ABI compatibility: mention Result guaranteeRalf Jung-0/+2