about summary refs log tree commit diff
path: root/library/alloc/src/raw_vec/tests.rs
AgeCommit message (Collapse)AuthorLines
2025-09-05RawVecInner: add missing `unsafe` to unsafe fnsBart Jacobs-5/+5
- RawVecInner::grow_exact causes UB if called with len and additional arguments such that len + additional is less than the current capacity. Indeed, in that case it calls Allocator::grow with a new_layout that is smaller than old_layout, which violates a safety precondition. - All RawVecInner methods for resizing the buffer cause UB if called with an elem_layout different from the one used to initially allocate the buffer, because in that case Allocator::grow/shrink is called with an old_layout that does not fit the allocated block, which violates a safety precondition. - RawVecInner::current_memory might cause UB if called with an elem_layout different from the one used to initially allocate the buffer, because the unchecked_mul might overflow. - Furthermore, these methods cause UB if called with an elem_layout where the size is not a multiple of the alignment. This is because Layout::repeat is used (in layout_array) to compute the allocation's layout when allocating, which includes padding to ensure alignment of array elements, but simple multiplication is used (in current_memory) to compute the old allocation's layout when resizing or deallocating, which would cause the layout used to resize or deallocate to not fit the allocated block, which violates a safety precondition.
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-2/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2024-08-09Polymorphize RawVecBen Kimock-19/+8
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-03-01try_with_capacity for RawVecKornel-3/+4
2023-12-11add more niches to rawvecThe 8472-0/+9
2021-11-26Add a unit test for zero-sized types in `RawVec`.Nicholas Nethercote-0/+84
Because there's some subtle behaviour specific to zero-sized types and it's currently not well tested.
2020-12-04 Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`Tim Diekmann-5/+5
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-3/+3
2020-09-22removing &mut self for other methods of AllocRefblitzerr-1/+1
2020-09-21replaced cell::update with cell::[g|s]etblitzerr-5/+1
2020-09-21Added feature flag to use cell_updateblitzerr-0/+4
2020-09-21Changing the alloc() to accept &self instead of &mut selfblitzerr-7/+8
2020-08-04Replace `Memoryblock` with `NonNull<[u8]>`Tim Diekmann-1/+1
2020-07-28Remove in-place allocation and revert to separate methods for zeroed allocationsTim Diekmann-2/+2
Fix docs
2020-07-27mv std libs to library/mark-0/+78