about summary refs log tree commit diff
path: root/src/liballoc/vec.rs
AgeCommit message (Collapse)AuthorLines
2020-04-30Rollup merge of #71148 - bluss:vec-drop-raw-slice, r=RalfJungTyler Mandry-4/+10
Vec drop and truncate: drop using raw slice *mut [T] By creating a *mut [T] directly (without going through &mut [T]), avoid questions of validity of the contents of the slice. Consider the following risky code: ```rust unsafe { let mut v = Vec::<bool>::with_capacity(16); v.set_len(16); } ``` The intention is that with this change, we avoid one of the soundness questions about the above snippet, because Vec::drop no longer produces a mutable slice of the vector's contents. r? @RalfJung
2020-04-28Vec IntoIter: Drop using raw sliceUlrik Sverdrup-2/+8
Update Vec drop with a comment to explain why we want to use a raw slice, and extend this pattern to also include the Vec's IntoIter.
2020-04-15Fix clippy warningsMatthias Krüger-6/+6
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
2020-04-14Vec drop and truncate: drop using raw slice *mut [T]Ulrik Sverdrup-2/+2
By creating a *mut [T] directly (without going through &mut [T]), avoid questions of validity of the contents of the slice. Consider the following risky code: ```rust unsafe { let mut v = Vec::<bool>::with_capacity(16); v.set_len(16); } ``` The intention is that with this change, the above snippet will be sound because Vec::drop does no longer produces a mutable slice of the vector's contents.
2020-04-06add detailed panic messages for Vec functionsIgorPerikov-6/+55
2020-04-05Rollup merge of #70558 - RalfJung:vec-extend-aliasing, r=AmanieuDylan DPC-9/+13
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-05tweak swap_removeRalf Jung-3/+4
2020-04-04use ManuallyDrop instead of forget inside collectionsTrevor Spiteri-14/+13
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-02Auto merge of #70362 - TimDiekmann:alloc-overhaul, r=Amanieubors-1/+2
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-03-30fix and test aliasing in swap_removeRalf Jung-3/+4
2020-03-30fix aliasing in remove()Ralf Jung-4/+2
also add smoke test to detect relocation even in rustc runs
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-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-26Fix issues from review and unsoundness of `RawVec::into_box`Tim Diekmann-1/+2
2020-03-26Overhaul of the `AllocRef` trait to match allocator-wg's latest consensTim Diekmann-1/+1
2020-03-20must_use on split_offKornel-0/+1
2020-03-11Rollup merge of #69828 - RalfJung:vec-leak, r=kennytmMazdak Farrokhzad-4/+12
fix memory leak when vec::IntoIter panics during drop Fixes https://github.com/rust-lang/rust/issues/69770
2020-03-10Allow vec.rs to be over 3000 lines :(Joshua Nelson-0/+1
2020-03-10Bump release cutoffJoshua Nelson-1/+1
2020-03-10make the impl a little prettierJoshua Nelson-1/+1
2020-03-10fix test failureJoshua Nelson-2/+7
2020-03-10limit From impl to LengthAtMost32Joshua Nelson-1/+4
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-03-10fix error compiling stage2Joshua Nelson-1/+1
Co-Authored-By: lzutao <taolzu@gmail.com>
2020-03-10impl From<[T; N]> for Vec<T>Joshua Nelson-0/+7
2020-03-09Vec::new is const tstable in 1.39 not 1.32Christopher Durham-1/+1
2020-03-08fix memory leak when vec::IntoIter panics during dropRalf Jung-4/+12
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-1/+1
fix various typos
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-01Rollup merge of #69568 - JOE1994:patch-2, r=Dylan-DPCDylan DPC-2/+3
Clarify explanation of Vec<T> 'fn resize' 1. Clarified on what should implement `Clone` trait. 2. Minor grammar fix: to be able clone => to be able **to** clone
2020-02-29clarify alignment requirements in Vec::from_raw_partsRalf Jung-1/+5
2020-02-29Remove trailing whitespaceYoungsuk Kim-1/+1
Removed trailing whitespace which caused to fail pretty-check
2020-02-29Update src/liballoc/vec.rs Youngsuk Kim-1/+1
Following suggestion from @jonas-schievink Co-Authored-By: Jonas Schievink <jonasschievink@gmail.com>
2020-02-28Clarify explanation of 'fn resize'Youngsuk Kim-2/+3
1. Clarified on what should implement 'Clone' trait. 2. Minor grammar fix: to be able clone => to be able to clone
2020-02-26Auto merge of #67290 - jonas-schievink:leak-audit, r=KodrAusbors-14/+35
Audit liballoc for leaks in `Drop` impls when user destructor panics Inspired by https://github.com/rust-lang/rust/pull/67243 and https://github.com/rust-lang/rust/pull/67235, this audits and hopefully fixes the remaining `Drop` impls in liballoc for resource leaks in the presence of panics in destructors called by the affected `Drop` impl. This does not touch `Hash{Map,Set}` since they live in hashbrown. They have similar issues though. r? @KodrAus
2020-01-31Fixed issue 68593hman523-0/+2
2020-01-28fix: typo in vec.rsPedro de Brito-1/+1
2020-01-19Update comments in `Drain`s `Drop` implJonas Schievink-3/+5
2020-01-19Fix leak in vec::IntoIter when a destructor panicsJonas Schievink-1/+3
2020-01-19Avoid leak in `vec::Drain` when item drop panicsJonas Schievink-13/+30
2020-01-11Revert "Rollup merge of #67727 - Dylan-DPC:stabilise/remove_item, ↵Lzu Tao-1/+2
r=alexcrichton" This reverts commit 4ed415b5478c74094c2859abfddb959588cd6bb1, reversing changes made to 3cce950743e8aa74a4378dfdefbbc80223a00865.
2020-01-07Rollup merge of #67929 - mgrachev:patch-1, r=jonas-schievinkYuki Okushi-1/+1
Formatting an example for method Vec.retain
2020-01-06stabilise itdylan_DPC-1/+1
2020-01-06stabilise remove_itemdylan_DPC-1/+0
2020-01-06Formatting an example for method Vec.retainGrachev Mikhail-1/+1
2020-01-05removed blank linedylan_DPC-1/+0
2020-01-04ef em ti ... :Pdylan_DPC-4/+3
2020-01-04add partial eq bound to remove_itemdylan_DPC-1/+8