diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-04-04 16:03:46 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-04-12 22:53:13 +0200 |
| commit | b017742136a5d02b6ba0f2080e97d18a8bfeba4b (patch) | |
| tree | bce8f7a832eb5cb80d05a45ef5e562c274b0ff6b /src/libstd | |
| parent | f9c96d70bd1471f662aa2ffdfe30ab6df69629d1 (diff) | |
| download | rust-b017742136a5d02b6ba0f2080e97d18a8bfeba4b.tar.gz rust-b017742136a5d02b6ba0f2080e97d18a8bfeba4b.zip | |
Return Result instead of Option in alloc::Layout constructors
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 2 | ||||
| -rw-r--r-- | src/libstd/error.rs | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index e9bdd4e7d07..50263705143 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -755,7 +755,7 @@ impl<K, V> RawTable<K, V> { } let buffer = Global.alloc(Layout::from_size_align(size, alignment) - .ok_or(CollectionAllocErr::CapacityOverflow)?)?; + .map_err(|_| CollectionAllocErr::CapacityOverflow)?)?; let hashes = buffer as *mut HashUint; diff --git a/src/libstd/error.rs b/src/libstd/error.rs index ec55a3c021a..3c209928d43 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -57,7 +57,7 @@ use cell; use char; use core::array; use fmt::{self, Debug, Display}; -use heap::{AllocErr, CannotReallocInPlace}; +use heap::{AllocErr, LayoutErr, CannotReallocInPlace}; use mem::transmute; use num; use str; @@ -250,6 +250,15 @@ impl Error for AllocErr { #[unstable(feature = "allocator_api", reason = "the precise API and guarantees it provides may be tweaked.", issue = "32838")] +impl Error for LayoutErr { + fn description(&self) -> &str { + "invalid parameters to Layout::from_size_align" + } +} + +#[unstable(feature = "allocator_api", + reason = "the precise API and guarantees it provides may be tweaked.", + issue = "32838")] impl Error for CannotReallocInPlace { fn description(&self) -> &str { CannotReallocInPlace::description(self) |
