about summary refs log tree commit diff
path: root/src/libcore/lib.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-301/+0
2020-07-27Rollup merge of #73858 - tspiteri:const-methods, r=oli-obkManish Goregaokar-2/+0
Make more primitive integer methods const Now that #72437 has been merged and `const_if_match` is stable, these methods can be stabilized const. The methods are grouped in commits according to feature names: * `const_nonzero_int_methods` - `NonZero*::new` * some `const_checked_int_methods` - `{i*,u*}::checked_add` - `{i*,u*}::checked_sub` - `{i*,u*}::checked_mul` - `{i*,u*}::checked_neg` - `{i*,u*}::checked_shl` - `{i*,u*}::checked_shr` - `i*::checked_abs` * `const_saturating_int_methods` - `{i*,u*}::saturating_add` - `{i*,u*}::saturating_sub` - `{i*,u*}::saturating_mul` - `i*::saturating_neg` - `i*::saturating_abs` * `const_int_sign` - `i*::signum` * `const_ascii_ctype_on_intrinsics` - `{char,u8}::is_ascii_alphabetic` - `{char,u8}::is_ascii_uppercase` - `{char,u8}::is_ascii_lowercase` - `{char,u8}::is_ascii_alphanumeric` - `{char,u8}::is_ascii_digit` - `{char,u8}::is_ascii_hexdigit` - `{char,u8}::is_ascii_punctuation` - `{char,u8}::is_ascii_graphic` - `{char,u8}::is_ascii_whitespace` - `{char,u8}::is_ascii_control`
2020-07-18Rollup merge of #74459 - canova:const-unreachable-unchecked, r=oli-obkManish Goregaokar-0/+1
Make unreachable_unchecked a const fn This PR makes `std::hint::unreachable_unchecked` a const fn so we can use it inside a const function. r? @RalfJung Fixes #53188.
2020-07-17Rollup merge of #72414 - KodrAus:feat/stdlazy, r=Mark-SimulacrumManish Goregaokar-0/+2
Add lazy initialization primitives to std Follow-up to #68198 Current RFC: https://github.com/rust-lang/rfcs/pull/2788 Rebased and fixed up a few of the dangling comments. Some notes carried over from the previous PR: - [ ] Naming. I'm ok to just roll with the `Sync` prefix like `SyncLazy` for now, but [have a personal preference for `Atomic`](https://github.com/rust-lang/rfcs/pull/2788#issuecomment-574466983) like `AtomicLazy`. - [x] [Poisoning](https://github.com/rust-lang/rfcs/pull/2788#discussion_r366725768). It seems like there's [some regret around poisoning in other `std::sync` types that we might want to just avoid upfront for `std::lazy`, especially if that would align with a future `std::mutex` that doesn't poison](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/parking_lot.3A.3AMutex.20in.20std/near/190331199). Personally, if we're adding these types to `std::lazy` instead of `std::sync`, I'd be on-board with not worrying about poisoning in `std::lazy`, and potentially deprecating `std::sync::Once` and `lazy_static` in favour of `std::lazy` down the track if it's possible, rather than attempting to replicate their behavior. cc @Amanieu @sfackler. - [ ] [Consider making`SyncOnceCell::get` blocking](https://github.com/matklad/once_cell/pull/92). There doesn't seem to be consensus in the linked PR on whether or not that's strictly better than the non-blocking variant. In general, none of these seem to be really blocking an initial unstable merge, so we could possibly kick off a FCP if y'all are happy? cc @matklad @pitdicker have I missed anything, or were there any other considerations that have come up since we last looked at this?
2020-07-18link once_cell feature to #74465Ashley Mannix-1/+1
2020-07-17Rollup merge of #74300 - lzutao:iterator-intra, r=jyn514Manish Goregaokar-0/+1
Use intra-doc links in core::iter module This will make core::iter doc depend less on std doc.
2020-07-17Rollup merge of #73930 - a1phyr:feature_const_option, r=dtolnayManish Goregaokar-0/+1
Make some Option methods const Tracking issue: #67441 Constantify the following methods of `Option`: - `as_ref` - `is_some` - `is_none` - `iter` (not sure about this one, but it is possible, and will be useful when const traits are a thing) cc @rust-lang/wg-const-eval @rust-lang/libs
2020-07-17Make unreachable_unchecked a const fnNazım Can Altınova-0/+1
2020-07-17Deny intra_doc_link_resolution_failure in libcoreLzu Tao-0/+1
2020-07-17Auto merge of #74395 - Mark-Simulacrum:stage0-next, r=pietroalbinibors-7/+4
Bump version to 1.47 This also bumps to a more recent rustfmt version, just to keep us relatively up to date (though almost nothing has changed in rustfmt we use beyond bumps to the parser infra). No formatting changes as a result of this. r? @pietroalbini
2020-07-16apply bootstrap cfgsMark Rousskov-7/+4
2020-07-17integrate Lazy into std layoutAshley Mannix-0/+2
This commit refactors the initial implementation to fit into std and makes some other changes: - use MaybeUninit internally in SyncOnceCell - correctly impl Drop for lazy::Once - port Lazy::take from once_cell from: https://github.com/matklad/once_cell/pull/100 Co-Authored-By: Paul Dicker <pitdicker@users.noreply.github.com>
2020-07-16Revert "Remove spotlight usage"Manish Goregaokar-0/+1
This reverts commit 13c6d5819aae3c0de6a90e7f17ea967bf4487cbb.
2020-07-15Constify most non-trait `Duration` methods as described in #72440marmeladema-0/+1
2020-07-14Rollup merge of #73986 - RalfJung:raw-slice-as-ptr, r=sfacklerManish Goregaokar-0/+1
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the https://github.com/rust-lang/rust/issues/71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes https://github.com/rust-lang/rust/issues/60639
2020-07-11Stabilize `transmute` in constants and statics but not const fnOliver Scherer-1/+1
2020-07-05add (unchecked) indexing methods to raw pointers and NonNullRalf Jung-1/+1
2020-07-05call the mut version as_mut_ptr and also add an as_ptr-like method to ↵Ralf Jung-0/+1
NonNull slices
2020-07-05variant_count: avoid incorrect dummy implementationRalf Jung-1/+1
2020-07-02Rollup merge of #73622 - LeSeulArtichaut:unsafe-libcore, r=nikomatsakisManish Goregaokar-1/+9
Deny unsafe ops in unsafe fns in libcore After `liballoc`, It's time for `libcore` :D I planned to do this bit by bit to avoid having a big chunk of diffs, so to make reviews easier, and to make the unsafe blocks narrower and take the time to document them properly. r? @nikomatsakis cc @RalfJung
2020-07-01Add feature const_optionBenoît du Garreau-0/+1
2020-07-01Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obkManish Goregaokar-0/+1
Make `likely` and `unlikely` const, gated by feature `const_unlikely` This PR also contains a fix to allow `#[allow_internal_unstable]` to work properly with `#[rustc_const_unstable]`. cc @RalfJung @nagisa r? @oli-obk
2020-06-30Stabilize `#[track_caller]`.Adam Perry-1/+1
Does not yet make its constness stable, though. Use of `Location::caller` in const contexts is still gated by `#![feature(const_caller_location)]`.
2020-06-30Deny unsafe ops in unsafe fns, part 6LeSeulArtichaut-1/+8
And final part!!!
2020-06-30Deny unsafe ops in unsafe fns, part 1LeSeulArtichaut-0/+1
2020-06-29stabilize const_ascii_ctype_on_intrinsicsTrevor Spiteri-1/+0
2020-06-29stabilize const_saturating_int_methodsTrevor Spiteri-1/+0
2020-06-28Auto merge of #72437 - ecstatic-morse:stabilize-const-if-match, r=oli-obkbors-2/+2
Stabilize `#![feature(const_if_match)]` Quoting from the [stabilization report](https://github.com/rust-lang/rust/issues/49146#issuecomment-616301045): > `if` and `match` expressions as well as the short-circuiting logic operators `&&` and `||` will become legal in all [const contexts](https://doc.rust-lang.org/reference/const_eval.html#const-context). A const context is any of the following: > > - The initializer of a `const`, `static`, `static mut` or enum discriminant. > - The body of a `const fn`. > - The value of a const generic (nightly only). > - The length of an array type (`[u8; 3]`) or an array repeat expression (`[0u8; 3]`). > > Furthermore, the short-circuiting logic operators will no longer be lowered to their bitwise equivalents (`&` and `|` respectively) in `const` and `static` initializers (see #57175). As a result, `let` bindings can be used alongside short-circuiting logic in those initializers. Resolves #49146. Ideally, we would resolve :whale: #66753 before this lands on stable, so it might be worth pushing this back a release. Also, this means we should get the process started for #52000, otherwise people will have no recourse except recursion for iterative `const fn`. r? @oli-obk
2020-06-28Remove uses of `const_loop` in `rustc`Dylan MacKenzie-1/+1
2020-06-28Remove `const_if_match` feature gate from librariesDylan MacKenzie-1/+1
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-2/+2
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-26Make `likely` and `unlikely` constGary Guo-0/+1
They are gated by internal feature gate const_likely
2020-06-24Implement intrinsicNathan Corbyn-0/+1
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-0/+1
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-20Add ClashingExternDecl lint.jumbatm-0/+3
This lint checks that all declarations for extern fns of the same name are declared with the same types.
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-0/+1
2020-06-13Stabilize Option::zipLzu Tao-1/+0
2020-05-25core: Make pointer offset methods "const fn"Joe Richey-0/+1
Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-18Add `len` and `slice_from_raw_parts` to `NonNull<[T]>`Simon Sapin-0/+2
This follows the precedent of the recently-added `<*const [T]>::len` (adding to its tracking issue https://github.com/rust-lang/rust/issues/71146) and `ptr::slice_from_raw_parts`.
2020-04-25Bump bootstrap compilerMark Rousskov-1/+1
2020-04-16Dogfood or_patterns in the standard libraryJosh Stone-0/+1
2020-03-29Auto merge of #70370 - petrochenkov:nosmatch, r=Centrilbors-1/+0
Remove attribute `#[structural_match]` and any references to it A small remaining part of https://github.com/rust-lang/rust/issues/63438.
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-0/+1
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-26introduce `negative_impls` feature gate and documentNiko Matsakis-0/+1
They used to be covered by `optin_builtin_traits` but negative impls are now applicable to all traits, not just auto traits. This also adds docs in the unstable book for the current state of auto traits.
2020-03-24Remove attribute `#[structural_match]` and any references to itVadim Petrochenkov-1/+0
2020-03-18add `Option::{zip,zip_with}` methods under "option_zip" gateWaffle-0/+1
This commit introduces 2 methods - `Option::zip` and `Option::zip_with` with respective signatures: - zip: `(Option<T>, Option<U>) -> Option<(T, U)>` - zip_with: `(Option<T>, Option<U>, (T, U) -> R) -> Option<R>` Both are under the feature gate "option_zip". I'm not sure about the name "zip", maybe we can find a better name for this. (I would prefer `union` for example, but this is a keyword :( ) -------------------------------------------------------------------------------- Recently in a russian rust begginers telegram chat a newbie asked (translated): > Are there any methods for these conversions: > > 1. `(Option<A>, Option<B>) -> Option<(A, B)>` > 2. `Vec<Option<T>> -> Option<Vec<T>>` > > ? While second (2.) is clearly `vec.into_iter().collect::<Option<Vec<_>>()`, the first one isn't that clear. I couldn't find anything similar in the `core` and I've come to this solution: ```rust let tuple: (Option<A>, Option<B>) = ...; let res: Option<(A, B)> = tuple.0.and_then(|a| tuple.1.map(|b| (a, b))); ``` However this solution isn't "nice" (same for just `match`/`if let`), so I thought that this functionality should be in `core`.
2020-03-15Bump the bootstrap compilerJonas Schievink-1/+1
2020-03-11Rollup merge of #69825 - lcnr:discriminant, r=oli-obkMazdak Farrokhzad-0/+1
make `mem::discriminant` const implements #69821, which could be used as a tracking issue for `const_discriminant`. Should this be added to the meta tracking issue #57563? @Lokathor
2020-03-11Rollup merge of #69373 - tspiteri:const_int_conversion, r=oli-obkMazdak Farrokhzad-1/+0
Stabilize const for integer {to,from}_{be,le,ne}_bytes methods All of these functions can be implemented simply and naturally as const functions, e.g. `u32::from_le_bytes` can be implemented as ```rust (bytes[0] as u32) | (bytes[1] as u32) << 8 | (bytes[2] as u32) << 16 | (bytes[3] as u32) << 24 ``` So stabilizing the constness will not expose that internally they are implemented using transmute which is not const in stable.
2020-03-10Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnisonMazdak Farrokhzad-1/+0
Remove spotlight I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it. r? @kinnison cc @ollie27