Commit Graph

91 Commits

Author SHA1 Message Date
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Ross MacArthur f7256d28d1 Require issue = "none" over issue = "0" in unstable attributes 2019-12-21 13:16:18 +02:00
Mark Mansi 7d268119f0 no need to bootstrap 2019-12-18 20:19:05 -06:00
Mark Mansi 253543560a add fixme 2019-12-18 20:19:05 -06:00
Mark Mansi 951f041347 fix import 2019-12-18 20:19:05 -06:00
Mark Mansi baaf864e07 use usize::MAX instead of !0 2019-12-18 20:19:05 -06:00
Mark Mansi 3ec3fca414 remove a bit more hackery 2019-12-18 20:19:05 -06:00
Mark Mansi 17aa0cb2ca Remove a const-if-hack in RawVec 2019-12-18 20:19:05 -06:00
Mazdak Farrokhzad d5fe5831ec Const-stabilize Vec::new. 2019-09-16 16:45:16 +02:00
Alexander Regueiro 58a26c8fc0 Update src/liballoc/raw_vec.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-14 15:26:50 +01:00
Alexander Regueiro b0006dff10 A few cosmetic improvements to code & comments in liballoc and libcore 2019-09-06 16:02:25 +01:00
Simon Sapin 59a340963f Add the Layout of the failed allocation to TryReserveError::AllocError
… 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-16 18:08:37 +02:00
Simon Sapin 36b18a1901 Rename CollectionAllocError to TryReserveError 2019-08-16 18:08:06 +02:00
Vadim Petrochenkov 3d0d6ee271 liballoc: Unconfigure tests during normal build
Remove additional libcore-like restrictions from liballoc, turns out the testing works ok if the tests are a part of liballoc itself.
2019-08-02 01:59:01 +03:00
bors 890881f8f4 Auto merge of #60340 - mgeier:cap-vs-capacity, r=alexcrichton
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-07-25 18:45:42 +00:00
Matthias Geier abe3bdf257 Remove RawVec::cap()
As suggested in https://github.com/rust-lang/rust/pull/60340#issuecomment-493681032
2019-06-25 15:44:21 +02:00
Aleksey Kladov a23a77fb19 avoid materializing unintialized Boxes in RawVec 2019-05-27 11:15:31 +03:00
Matthias Geier 0967d28be7 Rename .cap() methods to .capacity()
... but leave the old names in there for backwards compatibility.
2019-04-27 22:43:10 +02:00
Simon Sapin fc928a18ba Stabilize the alloc crate.
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-04-12 20:07:30 +02:00
Alexander Regueiro 99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Mazdak Farrokhzad 2396780cda liballoc: revert nested imports style changes. 2019-02-03 08:27:44 +01:00
Mazdak Farrokhzad 748970dfa9 liballoc: apply uniform_paths. 2019-02-02 11:05:20 +01:00
Mazdak Farrokhzad f09f62f62c liballoc: adjust abolute imports + more import fixes. 2019-02-02 10:34:36 +01:00
Mazdak Farrokhzad 7693e3e666 liballoc: refactor & fix some imports. 2019-02-02 10:14:40 +01:00
Mazdak Farrokhzad e6e27924e1 liballoc: cargo check passes on 2018 2019-02-02 08:36:45 +01:00
Jonathan Behrens aa9bc68a1e RawVec doesn't always abort on allocation errors 2019-01-08 17:21:30 -05:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Alexander Regueiro ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Andy Russell 4e35cbb22e fix various typos in doc comments 2018-11-13 14:45:31 -05:00
kennytm 0dd88c9797 Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJung
Replace usages of ptr::offset with ptr::{add,sub}.

Rust provides these helper methods – so let's use them!
2018-08-21 22:05:30 +08:00
Corey Farwell 993fb93464 Replace usages of ptr::offset with ptr::{add,sub}. 2018-08-20 07:28:34 -04:00
Matthias Krüger 71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
Simon Sapin b0547cea0a Move core::alloc::CollectionAllocErr to alloc::collections 2018-06-29 14:01:33 +02:00
Simon Sapin 1acbb0a935 Make raw_vec perma-unstable and hidden 2018-06-29 14:01:33 +02:00
Simon Sapin 2b789bd057 Rename OOM to allocation error
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-18 21:41:24 +02:00
Simon Sapin 0081d8826b Remove some unneeded casts 2018-06-11 13:47:28 -07:00
Mike Hommey f6ab74b8e7 Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAlloc 2018-06-11 13:47:23 -07:00
Mike Hommey 0f4ef003ac Pass a Layout to oom
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-30 05:35:48 +09:00
Mike Hommey 9c4e5b3b6c Restore RawVec::reserve* documentation
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-10 09:16:12 +09:00
Mike Hommey 663c0961b9 Cleanup a use in a raw_vec test
`allocator` is deprecated in favor of `alloc`, and `Alloc` is already imported
through `super::*`.
2018-05-08 17:07:24 +09:00
Mark Mansi f9f992379d heh, logic is hard 2018-04-29 17:27:17 -05:00
Mark Mansi e5280e452f use const trick 2018-04-29 17:13:49 -05:00
Mark Mansi a2105b8e21 make RawVec::empty const 2018-04-25 16:42:57 -05:00
Mark Mansi 256096da9e Make Vec::new const 2018-04-25 16:33:02 -05:00
Steven Fackler 9e8f683476 Remove Alloc::oom 2018-04-22 10:08:49 -07:00
bors 3809bbf47c Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfackler
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-16 23:19:41 +00:00
Mike Hommey bd9ff8476d Cleanup liballoc use statements
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-14 08:43:13 +09:00
Alex Crichton 66c5e3ffb2 Reduce the size of panics in RawVec
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-13 07:04:23 -07:00
Simon Sapin f607a3872a Rename alloc::Void to alloc::Opaque 2018-04-12 22:53:22 +02:00
Mike Hommey fddf51ee0b Use NonNull<Void> instead of *mut u8 in the Alloc trait
Fixes #49608
2018-04-12 22:53:22 +02:00