@@ -101,16 +101,19 @@ pub use panicking::{take_handler, set_handler, PanicInfo, Location};
101101 across a recover boundary"]
102102pub trait RecoverSafe { }
103103
104- /// A marker trait representing types which do not contain an `UnsafeCell` by
105- /// value internally.
104+ /// A marker trait representing types where a shared reference is considered
105+ /// recover safe.
106+ ///
107+ /// This trait is namely not implemented by `UnsafeCell`, the root of all
108+ /// interior mutability.
106109///
107110/// This is a "helper marker trait" used to provide impl blocks for the
108111/// `RecoverSafe` trait, for more information see that documentation.
109112#[ unstable( feature = "recover" , reason = "awaiting feedback" , issue = "27719" ) ]
110113#[ rustc_on_unimplemented = "the type {Self} contains interior mutability \
111114 and a reference may not be safely transferrable \
112115 across a recover boundary"]
113- pub trait NoUnsafeCell { }
116+ pub trait RefRecoverSafe { }
114117
115118/// A simple wrapper around a type to assert that it is panic safe.
116119///
@@ -159,27 +162,28 @@ pub struct AssertRecoverSafe<T>(T);
159162// * Our custom AssertRecoverSafe wrapper is indeed recover safe
160163impl RecoverSafe for .. { }
161164impl < ' a , T : ?Sized > !RecoverSafe for & ' a mut T { }
162- impl < ' a , T : NoUnsafeCell + ?Sized > RecoverSafe for & ' a T { }
163- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for * const T { }
164- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for * mut T { }
165+ impl < ' a , T : RefRecoverSafe + ?Sized > RecoverSafe for & ' a T { }
166+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for * const T { }
167+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for * mut T { }
165168impl < T : RecoverSafe > RecoverSafe for Unique < T > { }
166- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Shared < T > { }
169+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Shared < T > { }
167170impl < T : ?Sized > RecoverSafe for Mutex < T > { }
168171impl < T : ?Sized > RecoverSafe for RwLock < T > { }
169172impl < T > RecoverSafe for AssertRecoverSafe < T > { }
170173
171174// not covered via the Shared impl above b/c the inner contents use
172175// Cell/AtomicUsize, but the usage here is recover safe so we can lift the
173176// impl up one level to Arc/Rc itself
174- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Rc < T > { }
175- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Arc < T > { }
177+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Rc < T > { }
178+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Arc < T > { }
176179
177- // Pretty simple implementations for the `NoUnsafeCell` marker trait, basically
178- // just saying that this is a marker trait and `UnsafeCell` is the only thing
179- // which doesn't implement it (which then transitively applies to everything
180- // else.
181- impl NoUnsafeCell for .. { }
182- impl < T : ?Sized > !NoUnsafeCell for UnsafeCell < T > { }
180+ // Pretty simple implementations for the `RefRecoverSafe` marker trait,
181+ // basically just saying that this is a marker trait and `UnsafeCell` is the
182+ // only thing which doesn't implement it (which then transitively applies to
183+ // everything else.
184+ impl RefRecoverSafe for .. { }
185+ impl < T : ?Sized > !RefRecoverSafe for UnsafeCell < T > { }
186+ impl < T > RefRecoverSafe for AssertRecoverSafe < T > { }
183187
184188impl < T > AssertRecoverSafe < T > {
185189 /// Creates a new `AssertRecoverSafe` wrapper around the provided type.
0 commit comments