about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2019-06-12 18:47:58 +0200
committerSimon Sapin <simon.sapin@exyr.org>2019-08-16 18:08:37 +0200
commit59a340963fa5d8b5507d95cd015f7ca2855ba151 (patch)
tree20ec73bf0c84a434d0d1192fc4216eb64e1d1161 /src/libstd
parenta92c29b2385f4999d4cd9ef7589f1fc07ef9cdfb (diff)
downloadrust-59a340963fa5d8b5507d95cd015f7ca2855ba151.tar.gz
rust-59a340963fa5d8b5507d95cd015f7ca2855ba151.zip
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
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/map.rs7
-rw-r--r--src/libstd/lib.rs1
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index db637a108cb..a0538986a22 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -2545,7 +2545,10 @@ fn map_entry<'a, K: 'a, V: 'a>(raw: base::RustcEntry<'a, K, V>) -> Entry<'a, K,
 fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> TryReserveError {
     match err {
         hashbrown::CollectionAllocErr::CapacityOverflow => TryReserveError::CapacityOverflow,
-        hashbrown::CollectionAllocErr::AllocErr { .. } => TryReserveError::AllocErr,
+        hashbrown::CollectionAllocErr::AllocErr { layout } => TryReserveError::AllocError {
+            layout,
+            non_exhaustive: (),
+        },
     }
 }
 
@@ -3405,7 +3408,7 @@ mod test_map {
             panic!("usize::MAX should trigger an overflow!");
         }
 
-        if let Err(AllocErr) = empty_bytes.try_reserve(MAX_USIZE / 8) {
+        if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE / 8) {
         } else {
             panic!("usize::MAX / 8 should trigger an OOM!")
         }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 1f48315d3f8..760d92f1d7b 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -251,6 +251,7 @@
 #![feature(concat_idents)]
 #![feature(const_cstr_unchecked)]
 #![feature(const_raw_ptr_deref)]
+#![feature(container_error_extra)]
 #![feature(core_intrinsics)]
 #![feature(custom_test_frameworks)]
 #![feature(doc_alias)]