about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2019-06-20Rollup merge of #60772 - timvermeulen:slice_iter_nth_back, r=scottmcmMazdak Farrokhzad-21/+68
Implement nth_back for slice::{Iter, IterMut} Part of #54054. I implemented `nth_back` as straightforwardly as I could, and then slightly changed `nth` to match `nth_back`. I believe I did so correctly, but please double-check 🙂 I also added the helper methods `zst_shrink`, `next_unchecked`, and `next_back_unchecked` to get rid of some duplicated code. These changes hopefully make this code easier to understand for new contributors like me. I noticed the `is_empty!` and `len!` macros which sole purpose seems to be inlining, according to the comment right above them, but the `is_empty` and `len` methods are already marked with `#[inline(always)]`. Does that mean we could replace these macros with method calls, without affecting anything? I'd love to get rid of them.
2019-06-20Rollup merge of #60454 - acrrd:issues/54054_skip, r=scottmcmMazdak Farrokhzad-0/+48
Add custom nth_back to Skip Implementation of nth_back for Skip. Part of #54054
2019-06-19Rollup merge of #60667 - oli-obk:raw_from_raw_parts, r=sfacklerMazdak Farrokhzad-16/+50
Add functions for building raw slices to libcore implement https://github.com/rust-lang/rust/issues/36925
2019-06-19Add functions to build raw slicesOliver Scherer-16/+50
2019-06-19Auto merge of #61945 - Centril:rollup-xdqo2mn, r=Centrilbors-1/+16
Rollup of 11 pull requests Successful merges: - #61505 (Only show methods that appear in `impl` blocks in the Implementors sections of trait doc pages) - #61701 (move stray run-pass const tests into const/ folder) - #61748 (Tweak transparent enums and unions diagnostic spans) - #61802 (Make MaybeUninit #[repr(transparent)]) - #61839 (ci: Add a script for generating CPU usage graphs) - #61842 (Remove unnecessary lift calls) - #61843 (Turn down the myriad-closures test) - #61896 (rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`.) - #61898 (syntax: Factor out common fields from `SyntaxExtension` variants) - #61938 (create an issue for miri even in status test-fail) - #61941 (Preserve generator and yield source for error messages) Failed merges: r? @ghost
2019-06-19Rollup merge of #61802 - mjbshaw:maybe-uninit-transparent, r=cramertjMazdak Farrokhzad-1/+16
Make MaybeUninit #[repr(transparent)] Tracking issue: #60405
2019-06-18Auto merge of #59625 - immunant:copy_variadics_typealias, r=eddybbors-44/+187
Refactor C FFI variadics to more closely match their C counterparts, and add Clone implementation We had to make some changes to expose `va_copy` and `va_end` directly to users (mainly for C2Rust, but not exclusively): - redefine the Rust variadic structures to more closely correspond to C: `VaList` now matches `va_list`, and `VaListImpl` matches `__va_list_tag` - add `Clone` for `VaListImpl` - add explicit `as_va_list()` conversion function from `VaListImpl` to `VaList` - add deref coercion from `VaList` to `VaListImpl` - add support for the `asmjs` target All these changes were needed for use cases like: ```Rust let mut ap2 = va_copy(ap); vprintf(fmt, ap2); va_end(&mut ap2); ```
2019-06-18Make MaybeUninit #[repr(transparent)]Michael Bradshaw-1/+16
Tracking issue: #60405
2019-06-17Expose `VaListImpl` as the Rust equivalent of `__va_list_tag` and implement ↵Andrei Homescu-44/+187
Clone for it.
2019-06-17Rollup merge of #61885 - scottmcm:slice-iter-len-opt, r=rkruppe,RalfJungMazdak Farrokhzad-4/+23
Help LLVM better optimize slice::Iter(Mut)::len r? @RalfJung I've included a codegen test that fails without this change as a demonstration of usefulness.
2019-06-15Help LLVM better optimize slice::Iter(Mut)::lenScott McMurray-4/+23
2019-06-15Rollup merge of #61844 - AaronKutch:master, r=CentrilMazdak Farrokhzad-39/+39
Change `...` to `..=` where applicable This is mainly to fix #61816, but I decided to manually check a few thousand `...` throughout the code base to check for any other cases. I think I found a documentation bug in `src\libsyntax\ast.rs` where both `1..` and `1...` where mentioned. If there is internal support for both `1..` and `1..=` (that can exist before error handling gets to it), then I can add that back. There were some other cases that look like `// struct Closure<'l0...'li, T0...Tj, CK, CS, U0...Uk> {`, `// <P0 as Trait<P1...Pn>>::Foo: 'a`, and `assert!(min <= max, "discriminant range is {}...{}", min, max);`, but I am not sure if I should change those. There are a bunch of cases in the `/test/` directory that could be changed, but I presume I should just leave those be.
2019-06-15Rollup merge of #61785 - RalfJung:as-ref, r=rkruppeMazdak Farrokhzad-3/+35
note some safety concerns of raw-ptr-to-ref casts
2019-06-14Change `...` to `..=` where applicableAaron Kutch-39/+39
2019-06-14note some safety concerns of raw-ptr-to-ref castsRalf Jung-3/+35
2019-06-13Rollup merge of #61720 - alexcrichton:libstd-cfg-if-dep, r=sfacklerMazdak Farrokhzad-106/+25
std: Remove internal definitions of `cfg_if!` macro This is duplicated in a few locations throughout the sysroot to work around issues with not exporting a macro in libstd but still wanting it available to sysroot crates to define blocks. Nowadays though we can simply depend on the `cfg-if` crate on crates.io, allowing us to use it from there!
2019-06-13Rollup merge of #61629 - petrochenkov:stdmac, r=alexcrichtonMazdak Farrokhzad-11/+11
Hygienize macros in the standard library Same as https://github.com/rust-lang/rust/pull/55597, but for all macros in the standard library. Nested macro calls will now call what they are intended to call rather than whatever is in the closest scope at call site. Technically this is a breaking change, so crater run would probably be useful. --- One exception that is not hygienized is calls to `panic!(...)`. Macros defined in libcore do not want to call `core::panic`. What they really want to call is either `std::panic` or `core::panic` depending on `no_std` settings. EDIT: After some thought, recursive calls to `panic` from `panic` itself probably do want to use `$crate` (UPDATE: done). Calling `std::panic` from macros defined in std and "whatever `panic` is in scope" from macros defined in libcore is probably even worse than always calling "whatever `panic` is in scope", so I kept the existing code. The only way to do the std/core switch correctly that I'm aware of is to define a built-in panic macro that would dispatch to `std::panic` or `core::panic` using compiler magic. Then standard library macros could delegate to this built-in macro. The macro could be named `panic` too, that would fix https://github.com/rust-lang/rust/issues/61567. (This PR doesn't do that.) --- cc https://github.com/rust-lang/rust/issues/56389 cc https://github.com/rust-lang/rust/issues/61567 Fixes https://github.com/rust-lang/rust/issues/61699 r? @alexcrichton
2019-06-13Rollup merge of #61398 - kennytm:stabilize-copy-within, r=SimonSapinMazdak Farrokhzad-5/+17
Stabilize copy_within Closes #54236.
2019-06-13Rollup merge of #60376 - lzutao:stabilize-option_xor, r=SimonSapinMazdak Farrokhzad-3/+1
Stabilize Option::xor FCP done in https://github.com/rust-lang/rust/issues/50512#issuecomment-469527554 . Closes #50512 .
2019-06-12Hygienize macros in the standard libraryVadim Petrochenkov-11/+11
2019-06-12Rollup merge of #61671 - koalatux:nth-back-range, r=KodrAusMazdak Farrokhzad-0/+78
implement nth_back for Range(Inclusive) This is part of #54054.
2019-06-12Rollup merge of #61348 - dronesforwork-forks:clone-from, r=KodrAusMazdak Farrokhzad-2/+42
Implement Clone::clone_from for Option and Result See https://github.com/rust-lang/rust/issues/28481
2019-06-11Rollup merge of #61726 - cuviper:partition-for_each, r=scottmcmMazdak Farrokhzad-2/+2
Use `for_each` in `Iterator::partition` We already use this for `unzip`, but `partition` is not much different.
2019-06-11Rollup merge of #61724 - aschampion:128-bit-memcmp, r=sfacklerMazdak Farrokhzad-1/+1
core: use memcmp optimization for 128 bit integer slices All other sized integer slices do this. From #61665.
2019-06-11Rollup merge of #61715 - RalfJung:test-ascii-lowercase, r=varkorMazdak Farrokhzad-2/+2
make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone Cc https://github.com/rust-lang/rust/pull/61677 @napen123
2019-06-10Use `for_each` in `Iterator::partition`Josh Stone-2/+2
We already use this for `unzip`, but `partition` is not much different.
2019-06-10std: Remove internal definitions of `cfg_if!` macroAlex Crichton-106/+25
This is duplicated in a few locations throughout the sysroot to work around issues with not exporting a macro in libstd but still wanting it available to sysroot crates to define blocks. Nowadays though we can simply depend on the `cfg-if` crate on crates.io, allowing us to use it from there!
2019-06-10core: use memcmp optimization for 128 bit integer slicesAndrew Champion-1/+1
2019-06-10Rollup merge of #61501 - RalfJung:intrinsics, r=rkruppeMazdak Farrokhzad-27/+16
get rid of real_intrinsics module instead import intrinsics locally in their wrapper functions. (These functions are wrapper functions as a preparation to fixing https://github.com/rust-lang/rust/issues/53871.)
2019-06-10make sure to_ascii_lowercase actually leaves upper-case non-ASCII characters ↵Ralf Jung-2/+2
alone
2019-06-09implement nth_back for RangeInclusiveAdrian Friedli-0/+48
2019-06-09Auto merge of #61691 - RalfJung:miri-slow, r=Centrilbors-0/+2
Miri: disable a slow test
2019-06-09Miri: disable a slow testRalf Jung-0/+2
2019-06-09Auto merge of #61677 - napen123:string-examples, r=sfacklerbors-0/+20
Add examples for make_ascii_{uppercase, lowercase} As the title says, this adds simple usage examples for make_ascii_uppercase and make_ascii_lowercase.
2019-06-08Add examples for make_ascii_{uppercase, lowercase}Napen123-0/+20
2019-06-08Remove unused `#![feature(custom_attribute)]`sVadim Petrochenkov-1/+0
2019-06-08implement nth_back for RangeAdrian Friedli-0/+30
2019-06-08Auto merge of #61620 - SimonSapin:as_cell, r=RalfJungbors-4/+2
Stabilize Cell::from_mut and as_slice_of_cells FCP: https://github.com/rust-lang/rust/issues/43038#issuecomment-499900463
2019-06-08Auto merge of #61635 - ecstatic-morse:const-signum, r=oli-obkbors-6/+3
Make `i*::signum` a `const fn`. Ticks a box in #53718. This uses a well-known branchless implementation of `signum`: `(n > 0) as i32 - (n < 0) as i32`. Here's a [playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=747cf191c4974bf66c9d75e509ae6e6e) comparing the two techniques. On x86 in release mode, the branchless implementation is able to replace a `mov` and `cmov` with a `sar` and `add`, so this should be a bit faster as well. ~~This is marked as a draft since I think I'll need to add `#[rustc_const_unstable]` somewhere. Perhaps the reviewer can point me in the right direction.~~
2019-06-07Make `i*::signum` a `const fn`.Dylan MacKenzie-6/+3
This uses a well-known branchless implementation of `signum`. Its `const`-ness is unstable and requires `#![feature(const_int_sign)]`.
2019-06-07Auto merge of #61130 - jonhoo:mem-take, r=SimonSapinbors-0/+55
Add std::mem::take as suggested in #61129 This PR implements #61129 by adding `std::mem::take`. The added function is equivalent to: ```rust std::mem::replace(dest, Default::default()) ``` This particular pattern is fairly common, especially when implementing `Future::poll`, where you often need to yield an owned value in `Async::Ready`. This change allows you to write ```rust return Async::Ready(std::mem::take(self.result)); ``` instead of ```rust return Async::Ready(std::mem::replace(self.result, Vec::new())); ``` EDIT: Changed name from `take` to `swap_default`. EDIT: Changed name back to `take`.
2019-06-07Rollup merge of #61599 - laumann:pin-docs-minor-edits, r=CentrilMazdak Farrokhzad-20/+21
libcore/pin: Minor grammar corrections for module documentation This is by no means exhaustive, but I noticed a few grammatical errors when reading the documentation, and decided just to push these. Some standard rules/guidelines I followed: * Do not split infinitives, ie "not to move" instead of "to not move" * Do not use "since" when you want to say "because" or "as" - the word "since" has a temporal meaning In addition: * Fix a small typo: "Similarily" should be "Similarly" * Delete double-spaces after full stop
2019-06-07Stabilize Cell::from_mut and as_slice_of_cellsSimon Sapin-4/+2
FCP: https://github.com/rust-lang/rust/issues/43038#issuecomment-499900463
2019-06-07libcore/pin: Minor grammar corrections for module documentationThomas Bracht Laumann Jespersen-20/+21
This is by no means exhaustive, but I noticed a few grammatical errors when reading the documentation, and decided just to push these. Some standard rules/guidelines I followed: * Do not split infinitives, ie "not to move" instead of "to not move" * Do not use "since" when you want to say "because" or "as" - the word "since" has a temporal meaning In addition: * Fix a small typo: "Similarily" should be "Similarly" * Delete double-spaces after full stop
2019-06-07Auto merge of #61408 - varkor:fmin-fmax-llvm-intrinsics, r=alexcrichtonbors-36/+67
Use LLVM intrinsics for floating-point min/max Resurrection of https://github.com/rust-lang/rust/pull/46926, now that the optimisation issues are fixed. I've confirmed locally that https://github.com/rust-lang/rust/pull/61384 solves the issues. I'm not sure if we're allowed to move the `min`/`max` methods from libcore to libstd: I can't quite tell what the status is from https://github.com/rust-lang/rust/issues/50145. However, this is necessary to use the intrinsics. Fixes https://github.com/rust-lang/rust/issues/18384. r? @SimonSapin cc @rkruppe @nikic
2019-06-06Rollup merge of #61376 - czipperz:bound-cloned, r=sfacklerMazdak Farrokhzad-1/+41
Add Bound::cloned() Suggested by #61356
2019-06-06Add intrinsics for floating-point min and maxvarkor-36/+67
2019-06-06Auto merge of #61583 - Centril:rollup-ug2cbfd, r=Centrilbors-2/+2
Rollup of 4 pull requests Successful merges: - #61556 (librustc_errors: Rename AnnotateRs -> AnnotateSnippet) - #61557 (rustbuild: Include `rustfmt` in deduplicated dependencies) - #61571 (Escape HashMap with backticks in needs_drop docs) - #61582 (submodules: update clippy from 20da8f45 to 71be6f62) Failed merges: r? @ghost
2019-06-06Rollup merge of #61571 - czipperz:needs_drop-doc-escape-HashMap, ↵Mazdak Farrokhzad-2/+2
r=Mark-Simulacrum Escape HashMap with backticks in needs_drop docs
2019-06-06Auto merge of #61494 - Mark-Simulacrum:move-to-cfg-bootstrap, r=alexcrichtonbors-5/+5
Utilize cfg(bootstrap) over cfg(stage0) Also removes stage1, stage2 cfgs being passed to rustc to ensure that stage1 and stage2 are only differentiated as a group (i.e., only through not bootstrap). Fixes #53582 r? @alexcrichton