@@ -101,16 +101,19 @@ pub use panicking::{take_handler, set_handler, PanicInfo, Location};
101
101
across a recover boundary"]
102
102
pub trait RecoverSafe { }
103
103
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.
106
109
///
107
110
/// This is a "helper marker trait" used to provide impl blocks for the
108
111
/// `RecoverSafe` trait, for more information see that documentation.
109
112
#[ unstable( feature = "recover" , reason = "awaiting feedback" , issue = "27719" ) ]
110
113
#[ rustc_on_unimplemented = "the type {Self} contains interior mutability \
111
114
and a reference may not be safely transferrable \
112
115
across a recover boundary"]
113
- pub trait NoUnsafeCell { }
116
+ pub trait RefRecoverSafe { }
114
117
115
118
/// A simple wrapper around a type to assert that it is panic safe.
116
119
///
@@ -159,27 +162,28 @@ pub struct AssertRecoverSafe<T>(T);
159
162
// * Our custom AssertRecoverSafe wrapper is indeed recover safe
160
163
impl RecoverSafe for .. { }
161
164
impl < ' 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 { }
165
168
impl < T : RecoverSafe > RecoverSafe for Unique < T > { }
166
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Shared < T > { }
169
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Shared < T > { }
167
170
impl < T : ?Sized > RecoverSafe for Mutex < T > { }
168
171
impl < T : ?Sized > RecoverSafe for RwLock < T > { }
169
172
impl < T > RecoverSafe for AssertRecoverSafe < T > { }
170
173
171
174
// not covered via the Shared impl above b/c the inner contents use
172
175
// Cell/AtomicUsize, but the usage here is recover safe so we can lift the
173
176
// 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 > { }
176
179
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 > { }
183
187
184
188
impl < T > AssertRecoverSafe < T > {
185
189
/// Creates a new `AssertRecoverSafe` wrapper around the provided type.
0 commit comments