about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-05-21Stabilize feature from_refStjepan Glavina-2/+2
2018-05-21Auto merge of #50739 - gnzlbg:vec_reserve, r=sfacklerbors-2/+2
Switch Vec from doubling size on growth to using RawVec's reserve On growth, Vec does not require to exactly double its size for correctness, like, for example, VecDeque does. Using reserve instead better expresses this intent. It also allows to reuse Excess capacity on growth and for better growth-policies to be provided by RawVec. r? @sfackler
2018-05-17Stabilise inclusive_range_methodsvarkor-1/+0
2018-05-17Auto merge of #50629 - Mark-Simulacrum:stage-step, r=alexcrichtonbors-76/+6
Switch to bootstrapping from 1.27 It's possible the Float trait could be removed from core, but I couldn't tell whether it was intended to be removed or not. @SimonSapin may be able to comment more here; we can presumably also do that in a follow up PR as this one is already quite large.
2018-05-17Switch to 1.26 bootstrap compilerMark Simulacrum-76/+6
2018-05-17Rename trans to codegen everywhere.Irina Popa-1/+1
2018-05-17Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichtonkennytm-0/+15
Implement From for more types on Cow This is basically https://github.com/rust-lang/rust/pull/48191, except that it should be implemented in a way that doesn't break third party crates.
2018-05-16Stabilize num::NonZeroU*Simon Sapin-1/+0
Tracking issue: https://github.com/rust-lang/rust/issues/49137
2018-05-14Switch Vec from doubling size on growth to using RawVec's reservegnzlbg-2/+2
On growth, Vec does not require to exactly double its size for correctness, like, for example, VecDeque does. Using reserve instead better expresses this intent. It also allows to reuse Excess capacity on growth and for better growth-policies to be provided by RawVec.
2018-05-12Auto merge of #50352 - porglezomp:btree-no-empty-alloc, r=Gankrobors-31/+128
Don't allocate when creating an empty BTree Following the discussion in #50266, this adds a static instance of `LeafNode` that empty BTrees point to, and then replaces it on `insert`, `append`, and `entry`. This avoids allocating for empty maps. Fixes #50266 r? @Gankro
2018-05-10Skip a memory-hungry test that OOMsAlex Crichton-0/+1
Attempting to fix https://travis-ci.org/rust-lang/rust/jobs/377407894 via some selective ignoring tests
2018-05-10Rollup merge of #50591 - glandium:cleanup, r=dtolnayAlex Crichton-56/+57
Restore RawVec::reserve* documentation When the RawVec::try_reserve* methods were added, they took the place of the ::reserve* methods in the source file, and new ::reserve* methods wrapping the new try_reserve* methods were created. But the documentation didn't move along, such that: - reserve_* methods are barely documented. - try_reserve_* methods have unmodified documentation from reserve_*, such that their documentation indicate they are panicking/aborting. This moves the documentation back to the right methods, with a placeholder documentation for the try_reserve* methods.
2018-05-10Rollup merge of #50588 - ExpHP:i-can-see-my-house-from-here, r=frewsxcvAlex Crichton-4/+4
Move "See also" disambiguation links for primitive types to top Closes #50384. <details> <summary>Images</summary> ![rust-slice](https://user-images.githubusercontent.com/1411280/39843148-caa41c3e-53b7-11e8-8123-b57c25a4d9e0.png) ![rust-isize](https://user-images.githubusercontent.com/1411280/39843146-ca94b384-53b7-11e8-85f3-3f5e5d353a05.png) </details> r? @steveklabnik
2018-05-10Rollup merge of #50575 - alexcrichton:faster-drain-drop, r=sfacklerAlex Crichton-3/+5
std: Avoid `ptr::copy` if unnecessary in `vec::Drain` This commit is spawned out of a performance regression investigation in #50496. In tracking down this regression it turned out that the `expand_statements` function in the compiler was taking quite a long time. Further investigation showed two key properties: * The function was "fast" on glibc 2.24 and slow on glibc 2.23 * The hottest function was memmove from glibc Combined together it looked like glibc gained an optimization to the memmove function in 2.24. Ideally we don't want to rely on this optimization, so I wanted to dig further to see what was happening. The hottest part of `expand_statements` was `Drop for Drain` in the call to `splice` where we insert new statements into the original vector. This *should* be a cheap operation because we're draining and replacing iterators of the exact same length, but under the hood memmove was being called a lot, causing a slowdown on glibc 2.23. It turns out that at least one of the optimizations in glibc 2.24 was that `memmove` where the src/dst are equal becomes much faster. [This program][prog] executes in ~2.5s against glibc 2.23 and ~0.3s against glibc 2.24, exhibiting how glibc 2.24 is optimizing `memmove` if the src/dst are equal. And all that brings us to what this commit itself is doing. The change here is purely to `Drop for Drain` to avoid the call to `ptr::copy` if the region being copied doesn't actually need to be copied. For normal usage of just `Drain` itself this check isn't really necessary, but because `Splice` internally contains `Drain` this provides a nice speed boost on glibc 2.23. Overall this should fix the regression seen in #50496 on glibc 2.23 and also fix the regression on Windows where `memmove` looks to not have this optimization. Note that the way `splice` was called in `expand_statements` would cause a quadratic number of elements to be copied via `memmove` which is likely why the tuple-stress benchmark showed such a severe regression. Closes #50496 [prog]: https://gist.github.com/alexcrichton/c05bc51c6771bba5ae5b57561a6c1cd3
2018-05-10Rollup merge of #50010 - ExpHP:slice-bounds, r=alexcrichtonAlex Crichton-134/+355
Give SliceIndex impls a test suite of girth befitting the implementation (and fix a UTF8 boundary check) So one day I was writing something in my codebase that basically amounted to `impl SliceIndex for (Bound<usize>, Bound<usize>)`, and I said to myself: *Boy, gee, golly! I never realized bounds checking was so tricky!* At some point when I had around 60 lines of tests for it, I decided to go see how the standard library does it to see if I missed any edge cases. ...That's when I discovered that libcore only had about 40 lines of tests for slicing altogether, and none of them even used `..=`. --- This PR includes: * **Literally the first appearance of the word `get_unchecked_mut` in any directory named `test` or `tests`.** * Likewise the first appearance of `get_mut` used with _any type of range argument_ in these directories. * Tests for the panics on overflow with `..=`. * I wanted to test on `[(); usize::MAX]` as well but that takes linear time in debug mode </3 * A horrible and ugly test-generating macro for the `should_panic` tests that increases the DRYness by a single order of magnitude (which IMO wasn't enough, but I didn't want to go any further and risk making the tests inaccessible to next guy). * Same stuff for str! * Actually, the existing `str` tests were pretty good. I just helped filled in the holes. * [A fix for the bug it caught](https://github.com/rust-lang/rust/issues/50002). (only one ~~sadly~~)
2018-05-10Restore RawVec::reserve* documentationMike Hommey-56/+57
When the RawVec::try_reserve* methods were added, they took the place of the ::reserve* methods in the source file, and new ::reserve* methods wrapping the new try_reserve* methods were created. But the documentation didn't move along, such that: - reserve_* methods are barely documented. - try_reserve_* methods have unmodified documentation from reserve_*, such that their documentation indicate they are panicking/aborting. This moves the documentation back to the right methods, with a placeholder documentation for the try_reserve* methods.
2018-05-09move See also links to topMichael Lamparski-4/+4
2018-05-09std: Avoid `ptr::copy` if unnecessary in `vec::Drain`Alex Crichton-3/+5
This commit is spawned out of a performance regression investigation in #50496. In tracking down this regression it turned out that the `expand_statements` function in the compiler was taking quite a long time. Further investigation showed two key properties: * The function was "fast" on glibc 2.24 and slow on glibc 2.23 * The hottest function was memmove from glibc Combined together it looked like glibc gained an optimization to the memmove function in 2.24. Ideally we don't want to rely on this optimization, so I wanted to dig further to see what was happening. The hottest part of `expand_statements` was `Drop for Drain` in the call to `splice` where we insert new statements into the original vector. This *should* be a cheap operation because we're draining and replacing iterators of the exact same length, but under the hood memmove was being called a lot, causing a slowdown on glibc 2.23. It turns out that at least one of the optimizations in glibc 2.24 was that `memmove` where the src/dst are equal becomes much faster. [This program][prog] executes in ~2.5s against glibc 2.23 and ~0.3s against glibc 2.24, exhibiting how glibc 2.24 is optimizing `memmove` if the src/dst are equal. And all that brings us to what this commit itself is doing. The change here is purely to `Drop for Drain` to avoid the call to `ptr::copy` if the region being copied doesn't actually need to be copied. For normal usage of just `Drain` itself this check isn't really necessary, but because `Splice` internally contains `Drain` this provides a nice speed boost on glibc 2.23. Overall this should fix the regression seen in #50496 on glibc 2.23 and also fix the regression on Windows where `memmove` looks to not have this optimization. Note that the way `splice` was called in `expand_statements` would cause a quadratic number of elements to be copied via `memmove` which is likely why the tuple-stress benchmark showed such a severe regression. Closes #50496 [prog]: https://gist.github.com/alexcrichton/c05bc51c6771bba5ae5b57561a6c1cd3
2018-05-09Rollup merge of #50527 - glandium:cleanup, r=sfacklerkennytm-1/+1
Cleanup a `use` in a raw_vec test `allocator` is deprecated in favor of `alloc`, and `Alloc` is already imported through `super::*`.
2018-05-09Rollup merge of #50511 - Manishearth:must-use, r=QuietMisdreavuskennytm-2/+4
Add some explanations for #[must_use] `#[must_use]` can be given a string argument which is shown whilst warning for things. We should add a string argument to most of the user-exposed ones. I added these for everything but the operators, mostly because I'm not sure what to write there or if we need anything there.
2018-05-09Rollup merge of #50460 - F001:const_string, r=kennytmkennytm-1/+3
Make `String::new()` const Following the steps of https://github.com/rust-lang/rust/pull/50233 , make `String::new()` a `const fn`.
2018-05-09Update features to 1.28.0George Burton-2/+2
2018-05-08Make an ensure_root_is_owned method to reduce duplicationC Jones-15/+10
Also remove some unnecessary debug_assert! when creating the shared root, since the root should be stored in the rodata and thus be impossible to accidentally modify.
2018-05-08Auto merge of #50497 - RalfJung:pinmut, r=withoutboatsbors-3/+3
Rename Pin to PinMut, and some more breaking changes As discussed at [1] §3 and [2] and [3], a formal look at pinning requires considering a distinguished "shared pinned" mode/typestate. Given that, it seems desirable to at least eventually actually expose that typestate as a reference type. This renames Pin to PinMut, freeing the name Pin in case we want to use it for a shared pinned reference later on. [1] https://www.ralfj.de/blog/2018/04/10/safe-intrusive-collections-with-pinning.html [2] https://github.com/rust-lang/rfcs/pull/2349#issuecomment-379250361 [3] https://github.com/rust-lang/rust/issues/49150#issuecomment-380488275 Cc @withoutboats
2018-05-08Cleanup a `use` in a raw_vec testMike Hommey-1/+1
`allocator` is deprecated in favor of `alloc`, and `Alloc` is already imported through `super::*`.
2018-05-07Add debug asserts and fix some violationsC Jones-0/+16
2018-05-07Make into_key_slice avoid taking out-of-bounds pointersC Jones-14/+34
2018-05-07Split into_slices() to avoid making extra slicesC Jones-25/+41
This splits into_slices() into into_key_slice() and into_val_slice(). While the extra calls would get optimized out, this is a useful semantic change since we call keys() while iterating, and we don't want to construct and out-of-bounds val() pointer in the process if we happen to be pointing to the shared static root. This also paves the way for doing the alignment handling conditional differently for the keys and values.
2018-05-07Don't drop the shared static nodeC Jones-8/+13
We modify the drop implementation in IntoIter to not drop the shared root
2018-05-07Add a statically allocated empty node for empty mapsC Jones-2/+43
This gives a pointer to that static empty node instead of allocating a new node, and then whenever inserting makes sure that the root isn't that empty node.
2018-05-07Make LeafNode #[repr(C)] and put the metadata before generic itemsC Jones-8/+12
This way we can safely statically allocate a LeafNode to use as the placeholder before allocating, and any type accessing it will be able to access the metadata at the same offset.
2018-05-07Add explanation for #[must_use] on string replace methodsManish Goregaokar-2/+4
2018-05-07Rename Pin to PinMutRalf Jung-3/+3
As discussed at [1] §3 and [2] and [3], a formal look at pinning requires considering a distinguished "shared pinned" mode/typestate. Given that, it seems desirable to at least eventually actually expose that typestate as a reference type. This renames Pin to PinMut, freeing the name Pin in case we want to use it for a shared pinned reference later on. [1] https://www.ralfj.de/blog/2018/04/10/safe-intrusive-collections-with-pinning.html [2] https://github.com/rust-lang/rfcs/pull/2349#issuecomment-379250361 [3] https://github.com/rust-lang/rust/issues/49150#issuecomment-380488275
2018-05-06Use ManuallyDrop instead of Option in Hole implementationNikita Popov-6/+5
The Option is always Some until drop, where it becomes None. Make this more explicit and avoid unwraps by using ManuallyDrop. This change should be performance-neutral as LLVM already optimizes the unwraps away in the inlined code.
2018-05-05make `String::new()` constF001-1/+3
2018-05-01Auto merge of #49724 - kennytm:range-inc-start-end-methods, r=Kimundibors-2/+2
Introduce RangeInclusive::{new, start, end} methods and make the fields private. cc #49022
2018-04-30Auto merge of #48925 - zackmdavis:fn_must_stabilize, r=nikomatsakisbors-1/+2
stabilize `#[must_use]` for functions and must-use comparison operators (RFC 1940) r? @nikomatsakis
2018-05-01Rollup merge of #50233 - mark-i-m:const_vec, r=kennytmkennytm-5/+9
Make `Vec::new` a `const fn` `RawVec::empty/_in` are a hack. They're there because `if size_of::<T> == 0 { !0 } else { 0 }` is not allowed in `const` yet. However, because `RawVec` is unstable, the `empty/empty_in` constructors can be removed when #49146 is done...
2018-04-30revise test gen macro for strMichael Lamparski-144/+81
2018-04-30Make the fields of RangeInclusive private.kennytm-2/+2
Added new()/start()/end() methods to RangeInclusive. Changed the lowering of `..=` to use RangeInclusive::new().
2018-04-30decrease false negatives for str overflow testMichael Lamparski-1/+3
2018-04-30flesh out tests for SliceIndexMichael Lamparski-99/+378
m*n lines of implementation deserves m*n lines of tests
2018-04-30collect str SliceIndex tests into a modMichael Lamparski-137/+140
GitHub users: I think you can add ?w=1 to the url for a vastly cleaner whitespace-ignoring diff
2018-04-29heh, logic is hardMark Mansi-1/+1
2018-04-29use const trickMark Mansi-24/+7
2018-04-28stabilize `#[must_use]` for functions and must-use operatorsZack M. Davis-1/+2
This is in the matter of RFC 1940 and tracking issue #43302.
2018-04-27Update the stable attributes to use the current nightly version numberGeorge Burton-2/+2
2018-04-28Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnikkennytm-0/+1
std: Mark `ptr::Unique` with `#[doc(hidden)]` `Unique` is now perma-unstable, so let's hide its docs.
2018-04-27Auto merge of #50097 - glandium:box_free, r=nikomatsakisbors-7/+17
Partial future-proofing for Box<T, A> In some ways, this is similar to @eddyb's PR #47043 that went stale, but doesn't cover everything. Notably, this still leaves Box internalized as a pointer in places, so practically speaking, only ZSTs can be practically added to the Box type with the changes here (the compiler ICEs otherwise). The Box type is not changed here, that's left for the future because I want to test that further first, but this puts things in place in a way that hopefully will make things easier.
2018-04-26not insta-stableMark Mansi-0/+2