about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-07-03 09:59:28 -0400
committerGitHub <noreply@github.com>2019-07-03 09:59:28 -0400
commita0fcf5e6aa80f7231a1eb8e26a9a7afe70bd3033 (patch)
tree6a0cd50470f95d18c2d07d8b976c8601f211e411
parent7a033aad9db3f7799981c0524d24bc47931be0d6 (diff)
parent7454b29efc76c9d029359e6900262206722f65dc (diff)
downloadrust-a0fcf5e6aa80f7231a1eb8e26a9a7afe70bd3033.tar.gz
rust-a0fcf5e6aa80f7231a1eb8e26a9a7afe70bd3033.zip
Rollup merge of #62304 - SimonSapin:safe, r=eddyb
HashMap is UnwindSafe

Fixes https://github.com/rust-lang/rust/issues/62301, a regression in 1.36.0-pre which was caused by hashbrown using `NonZero<T>` where the older hashmap used `Unique<T>`.
-rw-r--r--src/libstd/collections/hash/map.rs6
-rw-r--r--src/libstd/panic.rs6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 5a2fe2b244f..2925d8362c8 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -2608,6 +2608,12 @@ mod test_map {
     use realstd::collections::CollectionAllocErr::*;
     use realstd::usize;
 
+    // https://github.com/rust-lang/rust/issues/62301
+    fn _assert_hashmap_is_unwind_safe() {
+        fn assert_unwind_safe<T: crate::panic::UnwindSafe>() {}
+        assert_unwind_safe::<HashMap<(), crate::cell::UnsafeCell<()>>>();
+    }
+
     #[test]
     fn test_zero_capacities() {
         type HM = HashMap<i32, i32>;
diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs
index 7a3b5d30500..1d4fd98dd75 100644
--- a/src/libstd/panic.rs
+++ b/src/libstd/panic.rs
@@ -4,6 +4,7 @@
 
 use crate::any::Any;
 use crate::cell::UnsafeCell;
+use crate::collections;
 use crate::fmt;
 use crate::future::Future;
 use crate::pin::Pin;
@@ -285,6 +286,11 @@ impl RefUnwindSafe for atomic::AtomicBool {}
 #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")]
 impl<T> RefUnwindSafe for atomic::AtomicPtr<T> {}
 
+// https://github.com/rust-lang/rust/issues/62301
+#[stable(feature = "hashbrown", since = "1.36.0")]
+impl<K, V, S> UnwindSafe for collections::HashMap<K, V, S>
+    where K: UnwindSafe, V: UnwindSafe, S: UnwindSafe {}
+
 #[stable(feature = "catch_unwind", since = "1.9.0")]
 impl<T> Deref for AssertUnwindSafe<T> {
     type Target = T;