about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
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-10Apply suggestions from code reviewPaweł Romanowski-4/+5
Co-Authored-By: varkor <github@varkor.com>
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-09Fix more tests after revert of rustdoc cfg(test) featureOliver Middleton-6/+9
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-08core: use iterators for slice equality comparisonAndrew Champion-14/+2
2019-06-08core: check for pointer equality when comparing Eq slicesAndrew Champion-1/+24
Because Eq types must be reflexively equal, an equal-length slice to the same memory location must be equal.
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
2019-06-05Remove dereferenceChris Gregory-1/+1
Co-Authored-By: Steven Fackler <sfackler@gmail.com>
2019-06-05Take self by value (Self is Copy here)Chris Gregory-1/+1
2019-06-05Escape needs_drop in the needs_drop documentationChris Gregory-1/+1
2019-06-05Escape HashMap with backticks in needs_drop docsChris Gregory-1/+1
2019-06-05Utilize cfg(bootstrap) over cfg(stage0)Mark Rousskov-5/+5
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).
2019-06-05Aggregation of drive-by cosmetic changes.Alexander Regueiro-2/+2
2019-06-05Stabilize Option::xorLzu Tao-3/+1
2019-06-04Remove unneeded feature attr from atomic integers doctestsLzu Tao-8/+8
2019-06-03get rid of real_intrinsics moduleRalf Jung-27/+16
instead import intrinsics locally in their wrapper functions
2019-06-04Update src/libcore/tests/slice.rskennytm-1/+1
Co-Authored-By: Jack O'Connor <oconnor663@gmail.com>
2019-06-03add unchecked math intrinsicslcnr/Bastian Kauschke-0/+15