about summary refs log tree commit diff
path: root/src/liballoc/collections
AgeCommit message (Collapse)AuthorLines
2018-12-16Rollup merge of #56672 - ccouzens:master, r=nikicMazdak Farrokhzad-1/+5
Document time of back operations of a Linked List Popping and pushing from the end of a linked list is constant time. This documentation is already there for popping and pushing from the front. @bors: r+ 38fe8d2 rollup
2018-12-16Rollup merge of #56648 - RalfJung:btree, r=sfacklerMazdak Farrokhzad-57/+117
Fix BTreeMap UB BTreeMap currently causes UB by created a shared reference to a too-small allocation. This PR fixes that by introducing a `NodeHeader` type and using that until we really need access to the key/value arrays. Avoiding run-time checks in `into_key_slice` was somewhat tricky, see the comments embedded in the code. I also adjusted `as_leaf_mut` to return a raw pointer, because creating a mutable reference asserts that there are no aliases to the pointee, but that's not always correct: We use `as_leaf_mut` twice to create two mutable slices for keys and values; the second call overlaps with the first slice and hence is not a unique pointer. Fixes https://github.com/rust-lang/rust/issues/54957 Cc @nikomatsakis @Gankro
2018-12-15Add a note about why the unsafe is soundScott McMurray-0/+10
2018-12-15Add unstable VecDeque::rotate_{left|right}Scott McMurray-0/+102
2018-12-13Auto merge of #56161 - RalfJung:vecdeque-stacked-borrows, r=SimonSapinbors-1/+4
VecDeque: fix for stacked borrows `VecDeque` violates a version of stacked borrows where creating a shared reference is not enough to make a location *mutably accessible* from raw pointers (and I think that is the version we want). There are two problems: * Creating a `NonNull<T>` from `&mut T` goes through `&T` (inferred for a `_`), then `*const T`, then `NonNull<T>`. That means in this stricter version of Stacked Borrows, we cannot actually write to such a `NonNull` because it was created from a shared reference! This PR fixes that by going from `&mut T` to `*mut T` to `*const T`. * `VecDeque::drain` creates the `Drain` struct by *first* creating a `NonNull` from `self` (which is an `&mut VecDeque`), and *then* calling `self.buffer_as_mut_slice()`. The latter reborrows `self`, asserting that `self` is currently the unique pointer to access this `VecDeque`, and hence invalidating the `NonNull` that was created earlier. This PR fixes that by instead using `self.buffer_as_slice()`, which only performs read accesses and creates only shared references, meaning the raw pointer (`NonNull`) remains valid. It is possible that other methods on `VecDeque` do something similar, miri's test coverage of `VecDeque` is sparse to say the least. Cc @nikomatsakis @Gankro
2018-12-11TypoAlexis Beingessner-1/+1
Co-Authored-By: RalfJung <post@ralfj.de>
2018-12-10Document time of back operations of a Linked ListChris Couzens-1/+5
Popping and pushing from the end of a linked list is constant time. This documentation is already there for popping and pushing from the front. @bors: r+ 38fe8d2 rollup
2018-12-09avoid as_leaf_mut asserting exclusive accessRalf Jung-30/+33
2018-12-09fix BTree creating shared references that are not entirely in-boundsRalf Jung-29/+86
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-7/+7
2018-12-07Fix broken doc testCorey Farwell-1/+1
2018-12-07Drain only needs a shared referenceRalf Jung-7/+5
2018-12-07VecDeque::drain: make sure the 'drain' raw pointer is actually still usableRalf Jung-2/+7
2018-12-05Fix typo in variable nameCorey Farwell-1/+1
2018-12-04Replace usages of `..i + 1` ranges with `..=i`.Corey Farwell-9/+9
2018-12-04Add example of using the indexing operator to BTreeMap docsCorey Farwell-0/+3
2018-12-03Rollup merge of #56432 - ordovicia:shrink-to-issue, r=Centrilkennytm-2/+2
Update issue number of `shrink_to` methods to point the tracking issue Tracking issue: #56431
2018-12-03Rollup merge of #56401 - scottmcm:vecdeque-resize-with, r=dtolnaykennytm-33/+27
Move VecDeque::resize_with out of the impl<T:Clone> block I put this in the wrong `impl` block in https://github.com/rust-lang/rust/pull/56016, so fixing. Tracking issue for the unstable method: https://github.com/rust-lang/rust/issues/41758#issuecomment-443077953
2018-12-02avoid MaybeUninit::get_mut where it is not neededRalf Jung-2/+2
2018-12-02Update issue number of `shrink_to` methods to point the tracking issueHidehito Yabuuchi-2/+2
2018-11-30Move VecDeque::resize_with out of the impl<T:Clone> blockScott McMurray-33/+27
2018-11-17Add VecDeque::resize_withScott McMurray-1/+39
2018-11-15Rollup merge of #55901 - euclio:speling, r=petrochenkovPietro Albini-1/+1
fix various typos in doc comments
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-11-06Format BtreeMap::range_mut examplekngwyu-3/+4
2018-10-28msp430: fix compilation of liballocJorge Aparicio-0/+2
2018-10-23fix typos in various placesMatthias Krüger-1/+1
2018-10-10remove a now outdated commentRalf Jung-3/+0
2018-10-09address RalfJung's commentJorge Aparicio-6/+6
2018-10-09alloc: fix deprecated warningsJorge Aparicio-20/+20
2018-10-05Revert "Slightly refactor VecDeque implementation"Alex Crichton-3/+3
This reverts commit 6ce76acae455a32113116cd2f95f8076388fc2d3.
2018-10-05Revert "Optimize VecDeque::append"Alex Crichton-27/+2
This reverts commit 11e488b64fed181820280d494d4fcc157ee1adc5.
2018-10-05Revert "Add docs and debug asserts"Alex Crichton-23/+11
This reverts commit 1a1a7f6167edf18b8a0ab488e651f7748cc2e9d3.
2018-10-05Revert "Fix tidy"Alex Crichton-2/+1
This reverts commit 1908892d3f60008f265dfc25ac46db387c0ad6a0.
2018-10-05Revert "Add another assert"Alex Crichton-4/+0
This reverts commit 21d2a6c9868541ec9829ced9a5bae936b18741c5.
2018-09-29Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"Ralf Jung-20/+20
This reverts commit c6e3d7fa3113aaa64602507f39d4627c427742ff, reversing changes made to 4591a245c7eec9f70d668982b1383cd2a6854af5.
2018-09-22address RalfJung's commentJorge Aparicio-6/+6
2018-09-22alloc: fix deprecated warningsJorge Aparicio-20/+20
2018-09-04Breaking change upgradesMark Rousskov-1/+1
2018-08-29Add another assertMaloJaffre-0/+4
2018-08-28Fix tidyMaloJaffre-1/+2
2018-08-28Add docs and debug assertsMaloJaffre-11/+23
2018-08-24Optimize VecDeque::appendMaloJaffre-2/+27
2018-08-24Slightly refactor VecDeque implementationMaloJaffre-3/+3
2018-08-22Add a test for issue #53529MaloJaffre-0/+17
2018-08-22Fix unsoundness in VecDeque Debug implsMaloJaffre-8/+8
Fixes #53566.
2018-08-22Revert "Auto merge of #52553 - Pazzaz:vecdeque-append, r=SimonSapin"MaloJaffre-159/+2
This partially reverts commit d5b6b95aef94169b5dbe4dbb1357d4bab1fc9800, reversing changes made to 6b1ff19af36f7bbf1974579ec1b9bf2c8ccd595e. Fixes #53529. Cc: #53564.
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-45/+45
2018-08-18Auto merge of #52553 - Pazzaz:vecdeque-append, r=SimonSapinbors-2/+159
Non-naive implementation of `VecDeque.append` Replaces the old, simple implementation with a more manual (and **unsafe** 😱) one. I've added 1 more test and verified that it covers all 6 code paths in the function. This new implementation was about 60% faster than the old naive one when I tried benchmarking it.
2018-08-15Clarify unused_as_mut_slicesPazzaz-3/+6