about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2022-09-30Added more const_closure functionality.onestacked-49/+62
2022-09-29Fix integer overflow in `format!("{:.0?}", Duration::MAX)`beetrees-10/+29
2022-09-29Rollup merge of #102452 - granolocks:grammar-tweak, r=thomccDylan DPC-1/+1
fix minor ungrammatical sentence This fixes an innocuous ungrammatical sentence in example code in the `TryFrom` documentation.
2022-09-29Rollup merge of #102435 - GuillaumeGomez:improve-iterator-reduce-example, ↵Dylan DPC-14/+5
r=thomcc,vacuus Improve example of Iterator::reduce Fixes #81819. I took your example `@bstrie` from https://github.com/rust-lang/rust/issues/81819 and applied it here. r? `@thomcc`
2022-09-29Rollup merge of #102342 - jmillikin:nonzero-negation, r=scottmcmDylan DPC-0/+154
Add negation methods for signed non-zero integers. Performing negation with defined wrapping semantics (such as `wrapping_neg()`) on a non-zero integer currently requires unpacking to a primitive and re-wrapping. Since negation of non-zero signed integers always produces a non-zero result, it is safe to implement the various `*_neg()` methods for `NonZeroI{N}`. I'm not sure what to do about the `#[unstable(..., issue = "none")]` here -- should I file a tracking issue, or is that handled by the Rust dev team? ACP: https://github.com/rust-lang/libs-team/issues/105
2022-09-29Stabilize const_char_convertest31-6/+5
2022-09-29Split out from_u32_unchecked from const_char_convertest31-3/+3
It relies on the Option::unwrap function which is not const-stable (yet).
2022-09-29Stabilize `nonnull_slice_from_raw_parts`Yuki Okushi-8/+5
2022-09-29fix minor ungrammatical sentenceGabe Koss-1/+1
2022-09-29Rollup merge of #102368 - beetrees:nano-niche, r=joshtriplettYuki Okushi-46/+52
Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant` As the nanoseconds fields is always between `0` and `(NANOS_PER_SEC - 1)` inclusive, use the `rustc_layout_scalar_valid_range` attributes to create a niche in the nanosecond field of `Duration` and `Timespec` (which is used to implement unix `SystemTime` and non-apple unix `Instant`; windows `Instant` is implemented with `Duration` and therefore will also benefit). This change has the benefit of making `Option<T>` the same size as `T` for the previously mentioned types. Also shrinks the nanoseconds field of `Timespec` to a `u32` as nanoseconds do not need the extra range of an `i64`, shrinking `Timespec` by 4 bytes on 32-bit platforms. r? ```@joshtriplett```
2022-09-29Add `is_empty()` method to `core::ffi::CStr`.John Millikin-0/+28
2022-09-29Improve example of Iterator::reduceGuillaume Gomez-14/+5
2022-09-29nonzero_negation_ops: `inline(always)` -> `inline`.John Millikin-1/+1
2022-09-29nonzero_negation_ops: Set `issue = "102443"`.John Millikin-5/+5
2022-09-28Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiserbors-0/+38
Add `#[rustc_safe_intrinsic]` This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.
2022-09-28Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`beetrees-46/+52
2022-09-28Update result.rsMarijn Schouten-3/+0
Remove a FIXME whose code got moved away in https://github.com/rust-lang/rust/pull/62883.
2022-09-28Rollup merge of #102288 - mejrs:inner, r=compiler-errorsYuki Okushi-0/+1
Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`. This suggests various ways to get inside wrapper types if the method cannot be found on the wrapper type, but is present on the wrappee. For this PR, those wrapper types include `Localkey`, `MaybeUninit`, `RefCell`, `RwLock` and `Mutex`.
2022-09-28Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8KiYuki Okushi-1/+1
Stabilize bench_black_box This PR stabilize `feature(bench_black_box)`. ```rust pub fn black_box<T>(dummy: T) -> T; ``` The FCP was completed in https://github.com/rust-lang/rust/issues/64102. `@rustbot` label +T-libs-api -T-libs
2022-09-27Rollup merge of #101555 - jhpratt:stabilize-mixed_integer_ops, r=joshtriplettMatthias Krüger-37/+24
Stabilize `#![feature(mixed_integer_ops)]` Tracked and FCP completed in #87840. ````@rustbot```` label +T-libs-api +S-waiting-on-review +relnotes r? rust-lang/t-libs-api
2022-09-27Address feedbackmejrs-1/+1
2022-09-27Wrapper suggestionsmejrs-0/+1
2022-09-27Stabilize bench_black_boxUrgau-1/+1
2022-09-27doc: rewrite doc for uint::{carrying_add,borrowing_sub}Trevor Spiteri-31/+49
2022-09-27core: Mark all safe intrinsics with #[rustc_safe_intrinsic]Arthur Cohen-0/+38
2022-09-27introduce `{char, u8}::is_ascii_octdigit`Akshay-0/+65
2022-09-27Add negation methods for signed non-zero integers.John Millikin-0/+154
2022-09-26Auto merge of #102283 - ↵bors-12/+4
GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc Improve code example for Option::unwrap_or_default Fixes #100054. Follow-up of #102259. r? `@thomcc`
2022-09-26Rollup merge of #102326 - yancyribbens:splin-mut-doc-change, r=thomccMichael Howell-1/+1
rustdoc: Update doc comment for splitn_mut to include mutable in the … The doc comment for [splitn](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L2051:L2056) is the exact same as the comment for [splitn_mut](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L2079:L2084). The doc comment for `splitn_mut` should instead say it's working on a mutable subslice.
2022-09-26Rollup merge of #102322 - sigaloid:master, r=GuillaumeGomezMichael Howell-0/+7
Document that Display automatically implements ToString Closes #92941 r? rust-lang/docs
2022-09-26Rollup merge of #102283 - ↵Michael Howell-12/+4
GuillaumeGomez:option-code-example-unwrap-or-default, r=thomcc Improve code example for Option::unwrap_or_default Fixes #100054. Follow-up of #102259. r? ``@thomcc``
2022-09-26Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, ↵Scott McMurray-114/+35
NeverShortCircuit::wrap_mut_2_imp)).0` everywhere Also use that macro to replace a bunch of places that had custom closure-wrappers.
2022-09-26rustdoc: Update doc comment for splitn_mut to include mutable in the descriptionyancy-1/+1
2022-09-26Document that Display entails ToStringMatthew Esposito-0/+7
2022-09-26Improve code example for Option::unwrap_or_defaultGuillaume Gomez-12/+4
2022-09-26remove cfg(bootstrap)Pietro Albini-175/+5
2022-09-26replace stabilization placeholdersPietro Albini-5/+5
2022-09-26Rollup merge of #102263 - GuillaumeGomez:iterator-rposition-example, r=thomccfee1-dead-3/+3
Clarify Iterator::rposition code example Fixes #101095. r? `@thomcc`
2022-09-25Rollup merge of #102259 - gimbles:patch-1, r=joshtriplettfee1-dead-0/+1
Type-annotate and simplify documentation of Option::unwrap_or_default Part of #100054
2022-09-25Rollup merge of #102245 - ink-feather-org:const_cmp_by, r=fee1-deadfee1-dead-6/+49
Constify cmp_min_max_by. Constifies `core::cmp::{min, max}_by[_key]` behind the `const_cmp` #92391 feature gate, using `const_closure`.
2022-09-25Rollup merge of #102200 - ink-feather-org:const_default_impls, r=fee1-deadfee1-dead-2/+4
Constify Default impl's for Arrays and Tuples. Allows to create arrays and tuples in const Context using the ~const Default implementation of the inner type.
2022-09-25Rollup merge of #101800 - chriss0612:feat/const_split_at_mut, r=fee1-deadfee1-dead-2/+5
Constify slice.split_at_mut(_unchecked) Tracking Issue: [Tracking Issue for const_slice_split_at_mut](https://github.com/rust-lang/rust/issues/101804) Feature gate: `#![feature(const_slice_split_at_mut)]` Still requires const_mut_refs to be actually used, but this feature removes the need to manually re implement these functions in a user crate.
2022-09-25Rollup merge of #98111 - eggyal:issue-97982, r=GuillaumeGomezfee1-dead-11/+14
Clarify `[T]::select_nth_unstable*` return values In cases where the nth element is not unique within the slice, it is not correct to say that the values in the returned triplet include ones for "all elements" less/greater than that at the given index: indeed one (or more) such values would then also contain elements equal to that at the given index. The text proposed here clarifies exactly what is returned, but in so doing it is also documenting an implementation detail that previously wasn't detailed: namely that the returned slices are slices into the reordered slice. I don't think this can be contentious, because the lifetimes of those returned slices are bound to that of the original (now reordered) slice—so there really isn't any other reasonable implementation that could have this behaviour; but nevertheless it's probably best if `@rust-lang/libs-api` give it a nod? Fixes #97982 r? `@m-ou-se` `@rustbot` label +A-docs +C-bug +T-libs-api -T-libs
2022-09-25Clarify Iterator::rposition code exampleGuillaume Gomez-3/+3
2022-09-25Update option.rsGimgim-0/+1
2022-09-25Remove unused variable.Camille GILLOT-4/+0
2022-09-25Auto merge of #102169 - scottmcm:constify-some-conditions, r=thomccbors-25/+60
Make ZST checks in core/alloc more readable There's a bunch of these checks because of special handing for ZSTs in various unsafe implementations of stuff. This lets them be `T::IS_ZST` instead of `mem::size_of::<T>() == 0` every time, making them both more readable and more terse. *Not* proposed for stabilization. Would be `pub(crate)` except `alloc` wants to use it too. (And while it doesn't matter now, if we ever get something like #85836 making it a const can help codegen be simpler.)
2022-09-24Constify cmp_min_max_byonestacked-6/+49
2022-09-24Add some more documentationScott McMurray-0/+26
2022-09-24Auto merge of #102234 - matthiaskrgr:rollup-5cb20l1, r=matthiaskrgrbors-69/+152
Rollup of 8 pull requests Successful merges: - #100823 (Refactor some `std` code that works with pointer offstes) - #102088 (Fix wrongly refactored Lift impl) - #102109 (resolve: Set effective visibilities for imports more precisely) - #102186 (Add const_closure, Constify Try trait) - #102203 (rustdoc: remove no-op CSS `#source-sidebar { z-index }`) - #102204 (Make `ManuallyDrop` satisfy `~const Destruct`) - #102210 (diagnostics: avoid syntactically invalid suggestion in if conditionals) - #102226 (bootstrap/miri: switch to non-deprecated env var for setting the sysroot folder) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup