about summary refs log tree commit diff
path: root/src/liballoc/tests
AgeCommit message (Collapse)AuthorLines
2019-12-13Rollup merge of #67235 - jonas-schievink:vecdeque-leak, r=KodrAusMazdak Farrokhzad-0/+34
VecDeque: drop remaining items on destructor panic Closes https://github.com/rust-lang/rust/issues/67232
2019-12-13Rollup merge of #67243 - jonas-schievink:linkedlist-drop, r=KodrAusMazdak Farrokhzad-0/+107
LinkedList: drop remaining items when drop panics https://github.com/rust-lang/rust/pull/67235, but for `LinkedList`, which has the same issue. I've also copied over the other drop-related tests from `VecDeque` since AFAICT `LinkedList` didn't have any.
2019-12-12LinkedList: drop remaining items when drop panicsJonas Schievink-0/+107
2019-12-11Small Cow improvementsAndre Bogus-0/+3
2019-12-11VecDeque: drop remaining items on destructor panicJonas Schievink-0/+34
2019-12-07liballoc: ignore tests in Miri instead of removing them entirelyRalf Jung-16/+15
2019-12-01Rollup merge of #66890 - dtolnay:fmt4, r=Dylan-DPCMazdak Farrokhzad-186/+144
Format liballoc with rustfmt Same strategy as #66691 -- as with my previous formatting PRs, I am avoiding causing merge conflicts in other PRs by only touches those files that are not involved in any currently open PR. Files that appear in new PRs between when this PR is opened and when it makes it to the top of the bors queue will be reverted from this PR. The list of files involved in open PRs is determined by querying GitHub's GraphQL API [with this script](https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8). With the list of files from the script in outstanding_files, the relevant commands were: ``` $ find src/liballoc -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg liballoc outstanding_files | xargs git checkout -- ``` To confirm no funny business: ``` $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference ``` r? @Dylan-DPC
2019-12-01Rollup merge of #66662 - RalfJung:miri-test-liballoc, r=dtolnayMazdak Farrokhzad-14/+24
Miri: run panic-catching tests in liballoc I also converted two tests from using `thread::spawn(...).join()` just for catching panics, to `catch_panic`, so that Miri can run them.
2019-11-29Format liballoc with rustfmtDavid Tolnay-186/+144
2019-11-26Fix spelling typosBrian Wignall-1/+1
2019-11-23enable more panic-catching tests in MiriRalf Jung-4/+15
2019-11-22enable panic-catching tests in MiriRalf Jung-3/+6
2019-11-22use catch_panic instead of thread::spawn to catch panicsRalf Jung-8/+5
2019-11-22enable panic-catching tests in MiriRalf Jung-4/+3
2019-11-13Auto merge of #65637 - ssomers:master, r=scottmcmbors-0/+74
proposal for BTreeMap/Set min/max, #62924 - Which pair of names: #62924 lists the existing possibilities min/max, first/last, (EDIT) front/back, peek(/peek_back?). Iterators have next/next_back or next/last. I'm slightly in favour of first/last because min/max might suggest they search over the entire map, and front/back pretends they are only about position. - Return key only instead of pair like iterator does? - If not, then keep the _key_value suffix? ~~Also provide variant with mutable value? But there is no such variant for get_key_value.~~ - Look for and upgrade more usages of `.iter().next()` and such in the libraries? I only upgraded the ones I contributed myself, all very recently.
2019-10-31Auto merge of #65091 - sekineh:into-iter-sorted, r=KodrAusbors-4/+75
Implement ordered/sorted iterators on BinaryHeap as per #59278 I've implemented the ordered version of iterator on BinaryHeap as per #59278. # Added methods: * `.into_iter_sorted()` * like `.into_iter()`; but returns elements in heap order * `.drain_sorted()` * like `.drain()`; but returns elements in heap order * It's a bit _lazy_; elements are removed on drop. (Edit: it’s similar to vec::Drain) For `DrainSorted` struct, I implemented `Drop` trait following @scottmcm 's [suggestion](https://github.com/rust-lang/rust/issues/59278#issuecomment-537306925) # ~TODO~ DONE * ~I think I need to add more tests other than doctest.~ # **Notes:** * we renamed `_ordered` to `_sorted`, because the latter is more common in rust libs. (as suggested by @KodrAus )
2019-10-28Rollup merge of #64747 - ethanboxx:master, r=CentrilMazdak Farrokhzad-1/+0
Stabilize `Option::flatten` - PR: https://github.com/rust-lang/rust/pull/60256 - Tracking issue: https://github.com/rust-lang/rust/issues/60258 @elahn > I was trying to `flat_map()` and found `map().flatten()` does the trick. This has been on nightly for 4 months, can we stabilise it? @ethanboxx > @Centril Helped me get this merged. What is the stabilization process? @Centril > @ethanboxx I'd just file a PR to stabilize it and we'll ask T-libs to FCP. So here I am. I am was unsure what number to put in `since = "-"` so I copied what someone had done in a recent PR.
2019-10-25Remove unused `use`s.Hideki Sekine-4/+0
2019-10-25Add .into_iter_sorted() and .drain_sorted()Hideki Sekine-4/+79
* `.drain_sorted()` doc change suggested by @KodrAus
2019-10-23proposal for access to BTreeMap/BTreeSet first/last, #62924Stein Somers-0/+74
2019-10-19Rollup merge of #65226 - ssomers:master, r=blussMazdak Farrokhzad-1/+25
BTreeSet symmetric_difference & union optimized No scalability changes, but: - Grew the cmp_opt function (shared by symmetric_difference & union) into a MergeIter, with less memory overhead than the pairs of Peekable iterators now, speeding up ~20% on my machine (not so clear on Travis though, I actually switched it off there because it wasn't consistent about identical code). Mainly meant to improve readability by sharing code, though it does end up using more lines of code. Extending and reusing the MergeIter in btree_map might be better, but I'm not sure that's possible or desirable. This MergeIter probably pretends to be more generic than it is, yet doesn't declare to be an iterator because there's no need to, it's only there to help construct genuine iterators SymmetricDifference & Union. - Compact the code of #64820 by moving if/else into match guards. r? @bluss
2019-10-19Stabilize `Option::flatten`Ethan Brierley-1/+0
2019-10-19Rollup merge of #65174 - SimonSapin:zero-box, r=alexcrichtonMazdak Farrokhzad-0/+20
Fix zero-size uninitialized boxes Requesting a zero-size allocation is not allowed, return a dangling pointer instead. CC https://github.com/rust-lang/rust/issues/63291#issuecomment-538692745
2019-10-18Uninitialized boxes: add test for zero-size allocationsSimon Sapin-0/+20
2019-10-18BTreeSet symmetric_difference & union optimized, cleanedStein Somers-1/+25
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-9/+13
- Compatible with Emscripten 1.38.46-upstream or later upstream. - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the old incorrect wasm32 C call ABI with the correct one, preserving the old one as wasm32_bindgen_compat for wasm-bindgen compatibility. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-05Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, ↵Tyler Mandry-23/+9
r=alexcrichton" This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-04Fix ABI, run and fix more tests, re-enable CI for PRsThomas Lively-9/+23
2019-10-02Stabilize `slice::repeat` (feature `repeat_generic_slice`)Lzu Tao-1/+0
2019-10-01BTreeSet intersection, difference & is_subnet optimizationsStein Somers-18/+92
2019-09-29Fix `vec![x; n]` with null raw fat pointer zeroing the pointer metadataSimon Sapin-0/+48
https://github.com/rust-lang/rust/pull/49496 introduced specialization based on: ``` unsafe impl<T: ?Sized> IsZero for *mut T { fn is_zero(&self) -> bool { (*self).is_null() } } ``` … to call `RawVec::with_capacity_zeroed` for creating `Vec<*mut T>`, which is incorrect for fat pointers since `<*mut T>::is_null` only looks at the data component. That is, a fat pointer can be “null” without being made entirely of zero bits. This commit fixes it by removing the `?Sized` bound on this impl (and the corresponding `*const T` one). This regresses `vec![x; n]` with `x` a null raw slice of length zero, but that seems exceptionally uncommon. (Vtable pointers are never null, so raw trait objects would not take the fast path anyway. An alternative to keep the `?Sized` bound (or even generalize to `impl<U: Copy> IsZero for U`) would be to cast to `&[u8]` of length `size_of::<U>()`, but the optimizer seems not to be able to propagate alignment information and sticks with comparing one byte at a time: https://rust.godbolt.org/z/xQFkwL ---- Without the library change, the new test fails as follows: ``` ---- vec::vec_macro_repeating_null_raw_fat_pointer stdout ---- [src/liballoc/tests/vec.rs:1301] ptr_metadata(raw_dyn) = 0x00005596ef95f9a8 [src/liballoc/tests/vec.rs:1306] ptr_metadata(vec[0]) = 0x0000000000000000 thread 'vec::vec_macro_repeating_null_raw_fat_pointer' panicked at 'assertion failed: vec[0] == null_raw_dyn', src/liballoc/tests/vec.rs:1307:5 ```
2019-09-16Improve BTreeSet::Intersection::size_hintpcpthm-0/+11
The commented invariant that an iterator is smaller than other iterator was violated after next is called and two iterators are consumed at different rates.
2019-08-16Add the Layout of the failed allocation to TryReserveError::AllocErrorSimon Sapin-20/+20
… and add a separately-unstable field to force non-exhaustive matching (`#[non_exhaustive]` is no implemented yet on enum variants) so that we have the option to later expose the allocator’s error value. CC https://github.com/rust-lang/wg-allocators/issues/23
2019-08-16Rename CollectionAllocError to TryReserveErrorSimon Sapin-3/+3
2019-08-10Rollup merge of #63350 - iluuu1994:use-associated-type-bounds, r=CentrilMazdak Farrokhzad-4/+7
Use associated_type_bounds where applicable - closes #61738
2019-08-09Rollup merge of #63407 - RalfJung:miri-test-sizes, r=CentrilMazdak Farrokhzad-0/+27
reduce some test sizes in Miri
2019-08-09reduce some test sizes in MiriRalf Jung-0/+27
2019-08-09Add missing #![feature(associated_type_bounds)]Ilija Tovilo-0/+1
2019-08-09Merge pull request #1 from rust-lang/masterSayan Nandan-96/+490
Merge recent changes into master
2019-08-09Improve tests for liballoc/btree/setSayan Nandan-2/+2
2019-08-08Use associated_type_bounds where applicable - closes #61738Ilija Tovilo-4/+6
2019-08-02Remove some more `cfg(test)`sVadim Petrochenkov-3/+0
2019-07-29comments from @lzutaoMaximilian Roos-1/+1
2019-07-29impl Debug for CharsMaximilian Roos-0/+10
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-1/+0
rustbuild Remove some random unnecessary lint `allow`s
2019-07-13Auto merge of #61953 - Centril:shared-from-iter, r=RalfJungbors-0/+240
Add `impl<T> FromIterator<T> for Arc/Rc<[T]>` Add implementations of `FromIterator<T> for Arc/Rc<[T]>` with symmetrical logic. This also takes advantage of specialization in the case of iterators with known length (`TrustedLen`) to elide the final allocation/copying from a `Vec<T>` into `Rc<[T]>` because we can allocate the space for the `Rc<[T]>` directly when the size is known. This is the primary motivation and why this is to be preferred over `iter.collect::<Vec<_>>().into(): Rc<[T]>`. Moreover, this PR does some refactoring in some places. r? @RalfJung for the code cc @alexcrichton from T-libs
2019-07-08Auto merge of #61224 - aloucks:drain_filter, r=Gankrobors-0/+109
Prevent Vec::drain_filter from double dropping on panic Fixes: #60977 The changes in this PR prevent leaking and double-panicking in addition to double-drop. Tracking issue: #43244
2019-07-06Rollup merge of #62296 - RalfJung:memalign, r=alexcrichtonMazdak Farrokhzad-15/+17
request at least ptr-size alignment from posix_memalign Fixes https://github.com/rust-lang/rust/issues/62251
2019-07-03enable a few more tests in Miri and update the comment for othersRalf Jung-1/+0
2019-07-02test more possible overaligned requestsRalf Jung-15/+17