diff options
| author | bors <bors@rust-lang.org> | 2017-06-20 05:02:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-06-20 05:02:19 +0000 |
| commit | 1143eb26a2e405cdccbf6789c89d4581ad969868 (patch) | |
| tree | 81cb3feed88063287f8e090ff0b58f01cb891726 /src/libstd | |
| parent | e00c0401b8fd2c33dc25d2589fd3523e8defa93e (diff) | |
| parent | 55a629d496f9393dff5c3a8d4511bf2686bf365b (diff) | |
| download | rust-1143eb26a2e405cdccbf6789c89d4581ad969868.tar.gz rust-1143eb26a2e405cdccbf6789c89d4581ad969868.zip | |
Auto merge of #42313 - pnkfelix:allocator-integration, r=alexcrichton
Allocator integration Lets start getting some feedback on `trait Alloc`. Here is: * the `trait Alloc` itself, * the `struct Layout` and `enum AllocErr` that its API relies on * a `struct HeapAlloc` that exposes the system allocator as an instance of `Alloc` * an integration of `Alloc` with `RawVec` * ~~an integration of `Alloc` with `Vec`~~ TODO * [x] split `fn realloc_in_place` into `grow` and `shrink` variants * [x] add `# Unsafety` and `# Errors` sections to documentation for all relevant methods * [x] remove `Vec` integration with `Allocator` * [x] add `allocate_zeroed` impl to `HeapAllocator` * [x] remove typedefs e.g. `type Size = usize;` * [x] impl `trait Error` for all error types in PR * [x] make `Layout::from_size_align` public * [x] clarify docs of `fn padding_needed_for`. * [x] revise `Layout` constructors to ensure that [size+align combination is valid](https://github.com/rust-lang/rust/pull/42313#issuecomment-306845446) * [x] resolve mismatch re requirements of align on dealloc. See [comment](https://github.com/rust-lang/rust/pull/42313#issuecomment-306202489).
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/error.rs | 19 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs index f56e3a5d780..3d203429e7b 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -51,6 +51,7 @@ // coherence challenge (e.g., specialization, neg impls, etc) we can // reconsider what crate these items belong in. +use alloc::allocator; use any::TypeId; use cell; use char; @@ -221,6 +222,24 @@ impl Error for ! { fn description(&self) -> &str { *self } } +#[unstable(feature = "allocator_api", + reason = "the precise API and guarantees it provides may be tweaked.", + issue = "27700")] +impl Error for allocator::AllocErr { + fn description(&self) -> &str { + allocator::AllocErr::description(self) + } +} + +#[unstable(feature = "allocator_api", + reason = "the precise API and guarantees it provides may be tweaked.", + issue = "27700")] +impl Error for allocator::CannotReallocInPlace { + fn description(&self) -> &str { + allocator::CannotReallocInPlace::description(self) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Error for str::ParseBoolError { fn description(&self) -> &str { "failed to parse bool" } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 105f4026ec8..7c843711dbe 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -245,6 +245,7 @@ // std is implemented with unstable features, many of which are internal // compiler details that will never be stable #![feature(alloc)] +#![feature(allocator_api)] #![feature(allow_internal_unstable)] #![feature(asm)] #![feature(associated_consts)] |
