about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-09-17Rollup merge of #64436 - llogiq:transmute-docs, r=RalfJungTyler Mandry-11/+17
improve Vec example soundness in mem::transmute docs The previous version of the `Vec` example had a case of questionable soundness, because at one point `v_orig` was aliased. r? @RalfJung
2019-09-17improve Vec example soundness in mem::transmute docsAndre Bogus-11/+17
2019-09-17Update src/libcore/pin.rsTaiki Endo-1/+1
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-09-17Add an example to Pin::as_mutTaiki Endo-0/+21
2019-09-17newly phrased documentation for spin loop hintsArno Haase-29/+20
2019-09-17Rollup merge of #64531 - taiki-e:pin-self, r=CentrilMazdak Farrokhzad-9/+9
Use shorthand syntax in the self parameter of methods of Pin
2019-09-17Rollup merge of #64530 - taiki-e:docs-pin-lifetimes, r=CentrilMazdak Farrokhzad-4/+4
Elide lifetimes in `Pin<&(mut) Self>`
2019-09-17Use shorthand syntax in the self parameter of methods of PinTaiki Endo-9/+9
2019-09-17Elide lifetimes in `Pin<&(mut) Self>`Taiki Endo-4/+4
2019-09-16Make some adjustments to the documentation for `std::convert::identity`varkor-8/+9
Fixes some extra blank lines and makes some minor tweaks to the wording.
2019-09-14Simplify Iterator::{min_by, max_by} using cmp::{min_by, max_by}Tim Vermeulen-31/+17
2019-09-14Add cmp::{min_by, min_by_key, max_by, max_by_key}Tim Vermeulen-3/+112
2019-09-14Rollup merge of #64203 - alexreg:rush-pr-2, r=centrilMazdak Farrokhzad-8/+8
A few cosmetic improvements to code & comments in liballoc and libcore Factored out from hacking on rustc for work on the REPL. r? @Centril
2019-09-13use `sign` variable in abs and wrapping_abs methodsTrevor Spiteri-3/+26
This also makes the code easier to understand by hinting at the significance of `self >> ($BITS - 1)` and by including an explanation in the comments. Also, now overflowing_abs simply uses wrapping_abs, which is clearer and avoids a potential performance regression in the LLVM IR.
2019-09-11Rollup merge of #64349 - arnohaase:pr_documentation_atomicptr, r=cramertjMazdak Farrokhzad-4/+2
documentation for AtomicPtr CAS operations The examples in the documentation for AtomicPtr CAS operations only show code that does *not* perform the CAS operation. I suggest to change them so that they actually do exchange the AtomicPtr's value.
2019-09-10Rollup merge of #63786 - tspiteri:const-abs, r=alexcrichtonMazdak Farrokhzad-21/+9
Make `abs`, `wrapping_abs`, `overflowing_abs` const functions This makes `abs`, `wrapping_abs` and `overflowing_abs` const functions like #58044 makes `wrapping_neg` and `overflowing_neg` const functions. `abs` is made const by returning `(self ^ -1) - -1` = `!self + 1` = `-self` for negative numbers and `(self ^ 0) - 0` = `self` for non-negative numbers. The subexpression `self >> ($BITS - 1)` evaluates to `-1` for negative numbers and `0` otherwise. The subtraction overflows when `self` is `min_value()`, as we would be subtracting `max_value() - -1`; this is when `abs` should overflow. `wrapping_abs` and `overflowing_abs` make use of `wrapping_sub` and `overflowing_sub` instead of the subtraction operator.
2019-09-10fixed linter errorArno Haase-14/+14
2019-09-10documentation for AtomicPtr CAS operationsArno Haase-4/+2
2019-09-10typo fixArno Haase-1/+1
2019-09-10documentation enhancement for 'spin loop hint': replace 'CPU' with 'CPU or core'Arno Haase-6/+6
2019-09-09Auto merge of #64313 - Centril:rollup-7w8b67g, r=Centrilbors-1/+78
Rollup of 5 pull requests Successful merges: - #63468 (Resolve attributes in several places) - #64121 (Override `StepBy::{try_fold, try_rfold}`) - #64278 (check git in bootstrap.py) - #64306 (Fix typo in config.toml.example) - #64312 (Unify escape usage) Failed merges: r? @ghost
2019-09-09Rollup merge of #64121 - timvermeulen:iter_step_by_internal, r=scottmcmMazdak Farrokhzad-1/+78
Override `StepBy::{try_fold, try_rfold}` Previous PR: https://github.com/rust-lang/rust/pull/51435 The previous PR was closed in favor of https://github.com/rust-lang/rust/pull/51601, which was later reverted. I don't think these implementations will make it harder to specialize `StepBy<Range<_>>` later, so we should be able to land this without any consequences. This should fix https://github.com/rust-lang/rust/issues/57517 – in my benchmarks `iter` and `iter.step_by(1)` now perform equally well, provided internal iteration is used.
2019-09-09Auto merge of #63118 - Centril:stabilize-bind-by-move, r=matthewjasperbors-1/+1
Stabilize `bind_by_move_pattern_guards` in Rust 1.39.0 Closes https://github.com/rust-lang/rust/issues/15287. After stabilizing `#![feature(bind_by_move_pattern_guards)]`, you can now use bind-by-move bindings in patterns and take references to those bindings in `if` guards of `match` expressions. For example, the following now becomes legal: ```rust fn main() { let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]); match array { nums // ---- `nums` is bound by move. if nums.iter().sum::<u8>() == 10 // ^------ `.iter()` implicitly takes a reference to `nums`. => { drop(nums); // --------- Legal as `nums` was bound by move and so we have ownership. } _ => unreachable!(), } } ``` r? @matthewjasper
2019-09-09document the unstable iter_order_by library featureAshley Mannix-3/+3
2019-09-08Rollup merge of #62205 - timvermeulen:iter_order_by, r=KodrAusMazdak Farrokhzad-6/+160
Add Iterator comparison methods that take a comparison function This PR adds `Iterator::{cmp_by, partial_cmp_by, eq_by, ne_by, lt_by, le_by, gt_by, ge_by}`. We already have `Iterator::{cmp, partial_cmp, ...}` which are less general (but not any simpler) than the ones I'm proposing here. I'm submitting this PR now because #61505 has been merged, so this change should not have a noticeable effect on the `Iterator` docs page size. The diff is quite messy, here's what I changed: - The logic of `cmp` / `partial_cmp` / `eq` is moved to `cmp_by` / `partial_cmp_by` / `eq_by` respectively, changing `x.cmp(&y)` to `cmp(&x, &y)` in the `cmp` method where `cmp` is the given comparison function (and similar for `partial_cmp_by` and `eq_by`). - `ne_by` / `lt_by` / `le_by` / `gt_by` / `ge_by` are each implemented in terms of one of the three methods above. - The existing comparison methods are each forwarded to their `_by` counterpart, passing one of `Ord::cmp` / `PartialOrd::partial_cmp` / `PartialEq::eq` as the comparison function. The corresponding `_by_key` methods aren't included because they're not as fundamental as the `_by` methods and can easily be implemented in terms of them. Is that reasonable, or would adding the `_by_key` methods be desirable for the sake of completeness? I didn't add any tests – I couldn't think of any that weren't already covered by our existing tests. Let me know if there's a particular test that would be useful to add.
2019-09-08bootstrap -> boostrap_stdarch_ignore_thisMazdak Farrokhzad-1/+1
2019-09-08Dont use gate bind_by_move_pattern_guards internally.Mazdak Farrokhzad-1/+1
2019-09-08Rollup merge of #64255 - varkor:bool-to-option, r=CentrilMazdak Farrokhzad-0/+55
Add methods for converting `bool` to `Option<T>` This provides a reference implementation for https://github.com/rust-lang/rfcs/pull/2757.
2019-09-07Support "soft" feature-gating using a lintVadim Petrochenkov-2/+4
Use it for feature-gating `#[bench]`
2019-09-07Add tracking issuevarkor-2/+2
2019-09-07Move `libcore/bool/mod.rs` to `libcore/bool.rs`varkor-3/+1
2019-09-07Add `bool::then` and `bool::then_with`varkor-1/+50
2019-09-07Add "bool" lang itemvarkor-0/+8
2019-09-06Rollup merge of #64208 - guanqun:py-is-not-none, r=matkladMazdak Farrokhzad-1/+1
it's more pythonic to use 'is not None' in python files
2019-09-06Rollup merge of #63969 - GuillaumeGomez:option-docs-example, r=sfacklerMazdak Farrokhzad-0/+31
Add missing examples for Option type cc @rust-lang/docs
2019-09-06A few cosmetic improvements to code & comments in liballoc and libcoreAlexander Regueiro-8/+8
2019-09-06Add Iterator comparison methods that take a comparison functionTim Vermeulen-6/+160
2019-09-06Rollup merge of #64174 - GuillaumeGomez:missing-iterator-examples, r=sfacklerMazdak Farrokhzad-0/+80
Add missing code examples on Iterator trait Fixes #63865 cc @rust-lang/docs
2019-09-06it's more pythonic to use 'is not None' in python filesGuanqun Lu-1/+1
2019-09-05Add missing code examples on Iterator traitGuillaume Gomez-0/+80
2019-09-05Rollup merge of #62848 - matklad:xid-unicode, r=petrochenkovMazdak Farrokhzad-408/+4
Use unicode-xid crate instead of libcore This PR proposes to remove `char::is_xid_start` and `char::is_xid_continue` functions from `libcore` and use `unicode_xid` crate from crates.io (note that this crate is already present in rust-lang/rust's Cargo.lock). Reasons to do this: * removing rustc-binary-specific stuff from libcore * making sure that, across the ecosystem, there's a single definition of what rust identifier is (`unicode-xid` has almost 10 million downs, as a `proc_macro2` dependency) * making it easier to share `rustc_lexer` crate with rust-analyzer: no need to `#[cfg]` if we are building as a part of the compiler Reasons not to do this: * increased maintenance burden: we'll need to upgrade unicode version both in libcore and in unicode-xid. However, this shouldn't be a too heavy burden: just running `./unicode.py` after new unicode version. I (@matklad) am ready to be a t-compiler side maintainer of unicode-xid. Moreover, given that xid-unicode is an important dependency of syn, *someone* needs to maintain it anyway. * xid-unicode implementation is significantly slower. It uses a more compact table with binary search, instead of a trie. However, this shouldn't matter in practice, because we have fast-path for ascii anyway, and code size savings is a plus. Moreover, in #59706 not using libcore turned out to be *faster*, presumably beacause checking for whitespace with match is even faster. <details> <summary>old description</summary> Followup to #59706 r? @eddyb Note that this doesn't actually remove tables from libcore, to avoid conflict with https://github.com/rust-lang/rust/pull/62641. cc https://github.com/unicode-rs/unicode-xid/pull/11 </details>
2019-09-05Rollup merge of #64142 - lzutao:fix-doc-cmp, r=jonas-schievinkMazdak Farrokhzad-6/+14
Fix doc links in `std::cmp` module r? @jonas-schievink
2019-09-05Rollup merge of #63985 - ghedo:stabilize_pin_into_inner, r=alexcrichtonMazdak Farrokhzad-2/+2
Stabilize pin_into_inner in 1.39.0 FCP: https://github.com/rust-lang/rust/issues/60245#issuecomment-522258129 Closes #60245
2019-09-05Rollup merge of #63549 - sfanxiang:rev-rposition, r=scottmcmMazdak Farrokhzad-7/+6
Rev::rposition counts from the wrong end Introduced in #43074. cc @SimonSapin
2019-09-04Update macros.rsStjepan Glavina-1/+1
2019-09-04Update src/libcore/macros.rsStjepan Glavina-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-04Fix doc links in `std::cmp` moduleLzu Tao-6/+14
These links are rendered in `core::cmp` but not in `std::cmp`.
2019-09-04Override `StepBy::{try_fold, try_rfold}`Tim Vermeulen-1/+78
2019-09-04remove XID and Pattern_White_Space unicode tables from libcoreAleksey Kladov-408/+4
They are only used by rustc_lexer, and are not needed elsewhere. So we move the relevant definitions into rustc_lexer (while the actual unicode data comes from the unicode-xid crate) and make the rest of the compiler use it.
2019-09-04Auto merge of #63166 - ksqsf:master, r=alexcrichtonbors-0/+81
Add Result::cloned{,_err} and Result::copied{,_err} This is a little nice addition to `Result`. 1. I'm not sure how useful are `cloned_err` and `copied_err`, but for the sake of completeness they are here. 2. Naming is similar to `map`/`map_err`. I thought about naming `cloned` as `cloned_ok` and add another method called `cloned` that clones both Ok and Err, but `cloned_ok` should be more prevalent than `cloned_both`.