未验证 提交 a0fcf5e6 编写于 作者: M Mark Rousskov 提交者: GitHub

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>`.
......@@ -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>;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册