about summary refs log tree commit diff
path: root/src/liballoc/tests/vec.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1629/+0
2020-06-22Rollup merge of #71660 - sollyucko:master, r=dtolnayDylan DPC-0/+54
impl PartialEq<Vec<B>> for &[A], &mut [A] https://github.com/rust-lang/rfcs/issues/2917
2020-06-20impl PartialEq<Vec<B>> for &[A], &mut [A]Solomon Ucko-0/+54
2020-06-20Remove uses of `Vec::remove_item`Lukas Kalbertodt-15/+0
2020-06-10Migrate to numeric associated constsLzu Tao-9/+9
2020-06-05Use assert_eq for liballoc testIvan Tham-1/+1
2020-05-18Tiny Vecs are dumb.Nicholas Nethercote-0/+115
Currently, if you repeatedly push to an empty vector, the capacity growth sequence is 0, 1, 2, 4, 8, 16, etc. This commit changes the relevant code (the "amortized" growth strategy) to skip 1 and 2 in most cases, instead using 0, 4, 8, 16, etc. (You can still get a capacity of 1 or 2 using the "exact" growth strategy, e.g. via `reserve_exact()`.) This idea (along with the phrase "tiny Vecs are dumb") comes from the "doubling" growth strategy that was removed from `RawVec` in #72013. That strategy was barely ever used -- only when a `VecDeque` was grown, oddly enough -- which is why it was removed in #72013. (Fun fact: until just a few days ago, I thought the "doubling" strategy was used for repeated push case. In other words, this commit makes `Vec`s behave the way I always thought they behaved.) This change reduces the number of allocations done by rustc itself by 10% or more. It speeds up rustc, and will also speed up any other Rust program that uses `Vec`s a lot.
2020-04-09Disable try_reserve tests on AndroidAmanieu d'Antras-0/+2
2020-04-05Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnayDylan DPC-1/+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-05Stop importing integer modules in liballocLinus Färnstrand-1/+0
2020-03-30fix and test aliasing in swap_removeRalf Jung-0/+5
2020-03-30fix aliasing in remove()Ralf Jung-1/+6
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-30add some testsRalf Jung-4/+18
2020-01-19FormatJonas Schievink-5/+1
2020-01-19Fix leak in vec::IntoIter when a destructor panicsJonas Schievink-0/+29
2020-01-19Avoid leak in `vec::Drain` when item drop panicsJonas Schievink-0/+39
2020-01-04ef em ti ... :Pdylan_DPC-3/+3
2020-01-04add testsdylan_DPC-0/+15
2019-12-22Format the worldMark Rousskov-116/+117
2019-12-07liballoc: ignore tests in Miri instead of removing them entirelyRalf Jung-2/+2
2019-12-01Rollup merge of #66662 - RalfJung:miri-test-liballoc, r=dtolnayMazdak Farrokhzad-3/+2
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-26Fix spelling typosBrian Wignall-1/+1
2019-11-22enable panic-catching tests in MiriRalf Jung-3/+2
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-2/+5
- 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-5/+2
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-2/+5
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-08-16Add the Layout of the failed allocation to TryReserveError::AllocErrorSimon Sapin-8/+8
… 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-1/+1
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-03enable a few more tests in Miri and update the comment for othersRalf Jung-1/+0
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-03-10we can now skip should_panic tests with the libtest harnessRalf Jung-12/+0
2019-02-13review failures in heap, slice, vecRalf Jung-0/+12
2019-02-09Rollup merge of #58275 - RalfJung:miri-test-libcore, r=Mark-SimulacrumMazdak Farrokhzad-0/+2
libcore, liballoc: disable tests in Miri I am going to run the libcore and liballoc unit test suites in Miri. Not all tests pass. This PR disables a whole bunch of tests when running in Miri, to get us to a baseline from which I can investigate failures. Cc @SimonSapin @alexcrichton
2019-02-07disable tests in MiriRalf Jung-0/+2
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-7/+5
2019-02-02liballoc: elide some lifetimes.Mazdak Farrokhzad-1/+1
2019-02-02liballoc: adjust abolute imports + more import fixes.Mazdak Farrokhzad-1/+1
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-5/+7
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-11Test capacity of ZST vectorKonrad Borowski-0/+5
Initially, #50233 accidentally changed the capacity of empty ZST. This was pointed out during code review. This commit adds a test to prevent capacity of ZST vectors from accidentally changing to prevent that from happening again.
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-8/+8
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-19/+1
Closes #22181, #27779