about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2020-04-06Use usize::MAX as assoc const in liballocLinus Färnstrand-2/+2
2020-04-06Use assoc const f32::NAN in liballocLinus Färnstrand-2/+2
2020-04-06BTreeMap first/last: add pop methodsStein Somers-0/+48
2020-04-06BTreeMap first/last: make examples more to the pointStein Somers-10/+12
2020-04-06BTreeMap first/last: simplify implementationsStein Somers-38/+16
2020-04-06add detailed panic messages for Vec functionsIgorPerikov-6/+55
2020-04-06Remove the Ord bound that was plaguing drain_filter, and superfluous lifetimesStein Somers-45/+21
2020-04-05Rollup merge of #70795 - Amanieu:btree_remove_tracking, r=Mark-SimulacrumDylan DPC-49/+64
Keep track of position when deleting from a BTreeMap This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap. cc @ssomers r? @Mark-Simulacrum
2020-04-05Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnayDylan DPC-10/+0
Don't import integer and float modules, use assoc consts Stop importing the standard library integer and float modules to reach the `MIN`, `MAX` and other constants. They are available directly on the primitive types now. This PR is a follow up of #69860 which made sure we use the new constants in documentation. This type of change touches a lot of files, and previously all my assoc int consts PRs had collisions and were accepted only after a long delay. So I'd prefer to do it in smaller steps now. Just removing these imports seem like a good next step. r? @dtolnay
2020-04-05Apply review feedbackAmanieu d'Antras-15/+10
2020-04-05Keep track of position when deleting from a BTreeMapAmanieu d'Antras-39/+59
This improves the performance of drain_filter and is needed for future Cursor support for BTreeMap.
2020-04-05Rollup merge of #70776 - RalfJung:raw-vec, r=Dylan-DPC,TimDiekmannDylan DPC-3/+6
clarify comment in RawVec::into_box On first reading I almost thought "len <= cap" would be all that there is to check here. Expand the comment to clarify that that is not the case.
2020-04-05Rollup merge of #70558 - RalfJung:vec-extend-aliasing, r=AmanieuDylan DPC-14/+79
Fix some aliasing issues in Vec `Vec::extend` and `Vec::truncate` invalidated references into the vector even without reallocation, because they (implicitly) created a mutable reference covering the *entire* initialized part of the vector. Fixes https://github.com/rust-lang/rust/issues/70301 I verified the fix by adding some new tests here that I ran in Miri.
2020-04-05clarify safety in RawVec::into_boxRalf Jung-3/+6
2020-04-05Stop importing integer modules in liballocLinus Färnstrand-10/+0
2020-04-05tweak swap_removeRalf Jung-3/+4
2020-04-04use ManuallyDrop instead of forget inside collectionsTrevor Spiteri-38/+34
This commit changes some usage of mem::forget into mem::ManuallyDrop in some Vec, VecDeque, BTreeMap and Box methods. Before the commit, the generated IR for some of the methods was longer, and even after optimization, some unwinding artifacts were still present.
2020-04-03Rollup merge of #69860 - faern:use-assoc-int-consts, r=dtolnayMazdak Farrokhzad-2/+2
Use associated numeric consts in documentation Now when the associated constants on int/float types are stabilized and the recommended way of accessing said constants (#68952). We can start using it in this repository, and recommend it via documentation example code. This PR is the reincarnation of #67913 minus the actual adding + stabilization of said constants. (EDIT: Now it's only changing the documentation. So users will see the new consts, but we don't yet update the internal code) Because of how fast bit rot happens to PRs that touch this many files, it does not try to replace 100% of the old usage of the constants in the entire repo, but a good chunk of them.
2020-04-03Fix link in task::Wake docsYoshua Wuyts-2/+4
2020-04-03Replace max/min_value() with MAX/MIN assoc constsLinus Färnstrand-2/+2
2020-04-02stabilize BTreeMap::remove_entryDutchGhost-2/+1
2020-04-02Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieubors-474/+391
Overhaul of the `AllocRef` trait to match allocator-wg's latest consens; Take 2 GitHub won't let me reopen #69889 so I make a new PR. In addition to #69889 this fixes the unsoundness of `RawVec::into_box` when using allocators supporting overallocating. Also it uses `MemoryBlock` in `AllocRef` to unify `_in_place` methods by passing `&mut MemoryBlock`. Additionally, `RawVec` now checks for `size_of::<T>()` again and ignore every ZST. The internal capacity of `RawVec` isn't used by ZSTs anymore, as `into_box` now requires a length to be specified. r? @Amanieu fixes rust-lang/wg-allocators#38 fixes rust-lang/wg-allocators#41 fixes rust-lang/wg-allocators#44 fixes rust-lang/wg-allocators#51
2020-04-01Add missing allocation guard in `RawVec::grow`Tim Diekmann-0/+1
2020-04-01Rollup merge of #70632 - tspiteri:vec-new, r=sfacklerDylan DPC-0/+6
expand vec![] to Vec::new() The current expansion of `vec![]` calls `into_vec` on a boxed slice, which results in longer IR, and even after optimization, some unwinding artifacts are still present in the IR. This PR uses `Vec::new()` for `vec![]`. This also allows `vec![]` to be used in const expressions.
2020-04-01Rollup merge of #68770 - ssomers:btree_drain_filter, r=AmanieuDylan DPC-14/+671
BTreeMap/BTreeSet: implement drain_filter Provide an implementation of drain_filter for BTreeMap and BTreeSet. Should be optimal when the predicate picks only elements in leaf nodes with at least MIN_LEN remaining elements, which is a common case, at least when draining only a fraction of the map/set, and also when the predicate picks elements stored in internal nodes where the right subtree can easily let go of a replacement element. The first commit adds benchmarks with an external, naive implementation. to compare how much this claimed optimality-in-some-cases is actually worth.
2020-03-31expand vec![] to Vec::new()Trevor Spiteri-0/+6
2020-03-31Rollup merge of #69425 - lcnr:make_contiguous, r=AmanieuDylan DPC-53/+235
add fn make_contiguous to VecDeque Adds the following method to VecDeque: ```rust pub fn make_contiguous(&mut self) -> &mut [T]; ``` Taken from https://github.com/rust-lang/rust/pull/69400, after a suggestion by @CryZe https://github.com/rust-lang/rust/pull/69400#issuecomment-590216089 I am in favor of merging this instead of https://github.com/rust-lang/rust/pull/69400.
2020-03-31fix docsBastian Kauschke-1/+1
2020-03-31Rollup merge of #69784 - benesch:fast-strip-prefix-suffix, r=kennytmMazdak Farrokhzad-0/+15
Optimize strip_prefix and strip_suffix with str patterns As mentioned in https://github.com/rust-lang/rust/issues/67302#issuecomment-585639226. I'm not sure whether adding these methods to `Pattern` is desirable—but they have default implementations so the change is backwards compatible. Plus it seems like they're slated for wholesale replacement soon anyway? #56345 ---- Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
2020-03-31update `VecDeque::as_(mut)_slice` docsBastian Kauschke-4/+4
2020-03-30Optimize strip_prefix and strip_suffix with str patternsNikhil Benesch-0/+15
Constructing a Searcher in strip_prefix and strip_suffix is unnecessarily slow when the pattern is a fixed-length string. Add strip_prefix and strip_suffix methods to the Pattern trait, and add optimized implementations of these methods in the str implementation. The old implementation is retained as the default for these methods.
2020-03-30Add inline attributes for functions used in the query systemJohn Kåre Alsaker-0/+1
2020-03-30fix and test aliasing in swap_removeRalf Jung-3/+9
2020-03-30fix aliasing in remove()Ralf Jung-5/+8
also add smoke test to detect relocation even in rustc runs
2020-03-30also cover next() path of draining iteratorsRalf Jung-4/+11
2020-03-30test more mutating vector methodsRalf Jung-0/+30
2020-03-30fix BTreeMap test compilation with MiriRalf Jung-1/+1
2020-03-30add some testsRalf Jung-4/+18
2020-03-30fix ptr invalidation in Vec::truncateRalf Jung-1/+2
2020-03-30fix pointer invalidation when extnding a vector from an untrusted iteratorRalf Jung-1/+3
2020-03-30fix Vec::extend invalidating unrelated pointersRalf Jung-1/+2
2020-03-29BTreeMap/BTreeSet: implement and test drain_filterStein Somers-20/+653
2020-03-29Add benchmarks of drain_filter-like behaviourStein Somers-0/+24
2020-03-29Rollup merge of #70506 - ssomers:btreemap_testing_consts, r=RalfJungMazdak Farrokhzad-41/+49
BTreeMap testing: introduce symbolic constants and use height consistently Doesn't change what or how much is tested, except for some exact integer types, just for convenience and because `node::CAPACITY` is a usize. r? @RalfJung
2020-03-29Rollup merge of #68692 - jyn514:vec-from-array, r=LukasKalbertodtMazdak Farrokhzad-0/+16
impl From<[T; N]> for Vec<T> Closes https://github.com/rust-lang/rust/issues/67963
2020-03-29Implement `init` and `init_offset` on `AllocInit` and mark it unsafeTim Diekmann-4/+4
2020-03-28BTreeMap testing: introduce symbolic constants and refer to height consistently.Stein Somers-41/+49
2020-03-28Make fields in `MemoryBlock` publicTim Diekmann-28/+29
2020-03-26Remove alignment from `MemoryBlock`Tim Diekmann-89/+65
2020-03-26Fix safety section of `RawVec::into_box`Tim Diekmann-1/+2