about summary refs log tree commit diff
path: root/src/liballoc/raw_vec.rs
AgeCommit message (Collapse)AuthorLines
2019-08-16Add the Layout of the failed allocation to TryReserveError::AllocErrorSimon Sapin-9/+11
… 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-6/+6
2019-08-02liballoc: Unconfigure tests during normal buildVadim Petrochenkov-79/+3
Remove additional libcore-like restrictions from liballoc, turns out the testing works ok if the tests are a part of liballoc itself.
2019-07-25Auto merge of #60340 - mgeier:cap-vs-capacity, r=alexcrichtonbors-59/+60
Rename .cap() methods to .capacity() As mentioned in #60316, there are a few `.cap()` methods, which seem out-of-place because such methods are called `.capacity()` in the rest of the code. This PR renames them to `.capacity()` but leaves `RawVec::cap()` in there for backwards compatibility. I didn't try to mark the old version as "deprecated", because I guess this would cause too much noise.
2019-06-25Remove RawVec::cap()Matthias Geier-6/+0
As suggested in https://github.com/rust-lang/rust/pull/60340#issuecomment-493681032
2019-05-27avoid materializing unintialized Boxes in RawVecAleksey Kladov-4/+6
2019-04-27Rename .cap() methods to .capacity()Matthias Geier-59/+66
... but leave the old names in there for backwards compatibility.
2019-04-12Stabilize the `alloc` crate.Simon Sapin-2/+2
This implements RFC 2480: * https://github.com/rust-lang/rfcs/pull/2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes https://github.com/rust-lang/rust/issues/27783
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-13/+9
2019-02-02liballoc: apply uniform_paths.Mazdak Farrokhzad-2/+2
2019-02-02liballoc: adjust abolute imports + more import fixes.Mazdak Farrokhzad-1/+1
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-11/+14
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-5/+5
2019-01-08RawVec doesn't always abort on allocation errorsJonathan Behrens-1/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-08-21Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJungkennytm-2/+2
Replace usages of ptr::offset with ptr::{add,sub}. Rust provides these helper methods – so let's use them!
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-2/+2
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-06-29Move core::alloc::CollectionAllocErr to alloc::collectionsSimon Sapin-2/+2
2018-06-29Make raw_vec perma-unstable and hiddenSimon Sapin-2/+5
2018-06-18Rename OOM to allocation errorSimon Sapin-6/+10
The acronym is not descriptive unless one has seen it before. * Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle. * Rename `set_oom_hook` to `set_alloc_error_hook` * Rename `take_oom_hook` to `take_alloc_error_hook` Bikeshed: `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-11Remove some unneeded castsSimon Sapin-3/+3
2018-06-11Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAllocMike Hommey-10/+9
2018-05-30Pass a `Layout` to `oom`Mike Hommey-74/+82
As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent, there are use-cases where the OOM handler needs to know the size of the allocation that failed. The alignment might also be a cause for allocation failure, so providing it as well can be useful.
2018-05-10Restore RawVec::reserve* documentationMike Hommey-56/+57
When the RawVec::try_reserve* methods were added, they took the place of the ::reserve* methods in the source file, and new ::reserve* methods wrapping the new try_reserve* methods were created. But the documentation didn't move along, such that: - reserve_* methods are barely documented. - try_reserve_* methods have unmodified documentation from reserve_*, such that their documentation indicate they are panicking/aborting. This moves the documentation back to the right methods, with a placeholder documentation for the try_reserve* methods.
2018-05-08Cleanup a `use` in a raw_vec testMike Hommey-1/+1
`allocator` is deprecated in favor of `alloc`, and `Alloc` is already imported through `super::*`.
2018-04-29heh, logic is hardMark Mansi-1/+1
2018-04-29use const trickMark Mansi-23/+6
2018-04-25make RawVec::empty constMark Mansi-1/+4
2018-04-25Make Vec::new constMark Mansi-0/+16
2018-04-22Remove Alloc::oomSteven Fackler-7/+7
2018-04-16Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfacklerbors-8/+15
std: Minimize size of panicking on wasm This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-14Cleanup liballoc use statementsMike Hommey-4/+5
Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2018-04-13Reduce the size of panics in RawVecAlex Crichton-8/+15
Create one canonical location which panics with "capacity overflow" instead of having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from 34k to 17k.
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-11/+11
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-21/+19
Fixes #49608
2018-04-12realloc with a new size only, not a full new layout.Simon Sapin-9/+8
Changing the alignment with realloc is not supported.
2018-04-12Return Result instead of Option in alloc::Layout constructorsSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr parameter of oom()Simon Sapin-6/+6
2018-04-12Make AllocErr a zero-size unit structSimon Sapin-1/+1
2018-04-12Actually deprecate the Heap typeSimon Sapin-12/+11
2018-04-02Use Alloc and Layout from core::heap.Mike Hommey-1/+2
94d1970bba87f2d2893f6e934e4c3f02ed50604d moved the alloc::allocator module to core::heap, moving e.g. Alloc and Layout out of the alloc crate. While alloc::heap reexports them, it's better to use them from where they really come from.
2018-03-14implementing fallible allocation API (try_reserve) for Vec, String and HashMapsnf-42/+60
2018-01-20Replace Unique<T> with NonZero<T> in Alloc traitSimon Sapin-1/+1
2017-11-01Fix typo.Lance John-1/+1
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-2/+2
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )