| Age | Commit message (Collapse) | Author | Lines |
|
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
|
|
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.
|
|
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
|
|
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.
|
|
|
|
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.
|
|
|
|
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.
|
|
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
|
|
|
|
also add smoke test to detect relocation even in rustc runs
|
|
|
|
|
|
|
|
impl From<[T; N]> for Vec<T>
Closes https://github.com/rust-lang/rust/issues/67963
|
|
|
|
|
|
|
|
fix memory leak when vec::IntoIter panics during drop
Fixes https://github.com/rust-lang/rust/issues/69770
|
|
|
|
|
|
|
|
|
|
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
|
Co-Authored-By: lzutao <taolzu@gmail.com>
|
|
|
|
|
|
|
|
fix various typos
|
|
|
|
|
|
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
|
|
|
|
Removed trailing whitespace which caused to fail pretty-check
|
|
Following suggestion from @jonas-schievink
Co-Authored-By: Jonas Schievink <jonasschievink@gmail.com>
|
|
1. Clarified on what should implement 'Clone' trait.
2. Minor grammar fix:
to be able clone => to be able to clone
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
r=alexcrichton"
This reverts commit 4ed415b5478c74094c2859abfddb959588cd6bb1, reversing
changes made to 3cce950743e8aa74a4378dfdefbbc80223a00865.
|
|
Formatting an example for method Vec.retain
|
|
|
|
|
|
|
|
|
|
|
|
|