about summary refs log tree commit diff
path: root/src/liballoc/tests
AgeCommit message (Collapse)AuthorLines
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-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
2019-06-21shared_from_iter: Polish internal docs.Mazdak Farrokhzad-0/+2
2019-06-21shared_from_iter: Add more tests.Mazdak Farrokhzad-0/+238
2019-05-27Disable drain_filter tests that require catch_unwind on miriAaron Loucks-0/+2
2019-05-27Add drain_filter_unconsumed testAaron Loucks-0/+8
2019-05-26Prevent Vec::drain_filter from double dropping on panicAaron Loucks-0/+99
Fixes: #60977
2019-05-25add test checking that Vec push/pop does not invalidate pointersRalf Jung-0/+21
2019-05-23fix dangling reference in Vec::appendRalf Jung-2/+3
2019-05-19Rollup merge of #60931 - cuviper:array-iter, r=KodrAusMazdak Farrokhzad-2/+2
Use iter() for iterating arrays by slice These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-17Use iter() for iterating arrays by sliceJosh Stone-2/+2
These `into_iter()` calls will change from iterating references to values if we ever get `IntoIterator` for arrays, which may break the code using that iterator. Calling `iter()` is future proof.
2019-05-09make vecdeque_rotate stableDodo-1/+0
2019-04-20Deny rust_2018_idioms in liballoc testsPhilipp Hansch-14/+15
2019-04-17test sort_unstable in MiriRalf Jung-3/+3
2019-04-16Miri now supports entropy, but is still slowRalf Jung-7/+16
2019-03-29improve worst-case performance of BTreeSet difference and intersectionStein Somers-0/+61
2019-03-16Rollup merge of #59206 - sntdevco:master, r=dtolnaykennytm-1/+1
Improved test output
2019-03-15Improved test output for liballoc/strsntdevco-1/+1