@@ -99,16 +99,19 @@ use thread::Result;
99
99
across a recover boundary"]
100
100
pub trait RecoverSafe { }
101
101
102
- /// A marker trait representing types which do not contain an `UnsafeCell` by
103
- /// value internally.
102
+ /// A marker trait representing types where a shared reference is considered
103
+ /// recover safe.
104
+ ///
105
+ /// This trait is namely not implemented by `UnsafeCell`, the root of all
106
+ /// interior mutability.
104
107
///
105
108
/// This is a "helper marker trait" used to provide impl blocks for the
106
109
/// `RecoverSafe` trait, for more information see that documentation.
107
110
#[ unstable( feature = "recover" , reason = "awaiting feedback" , issue = "27719" ) ]
108
111
#[ rustc_on_unimplemented = "the type {Self} contains interior mutability \
109
112
and a reference may not be safely transferrable \
110
113
across a recover boundary"]
111
- pub trait NoUnsafeCell { }
114
+ pub trait RefRecoverSafe { }
112
115
113
116
/// A simple wrapper around a type to assert that it is panic safe.
114
117
///
@@ -157,27 +160,28 @@ pub struct AssertRecoverSafe<T>(T);
157
160
// * Our custom AssertRecoverSafe wrapper is indeed recover safe
158
161
impl RecoverSafe for .. { }
159
162
impl < ' a , T : ?Sized > !RecoverSafe for & ' a mut T { }
160
- impl < ' a , T : NoUnsafeCell + ?Sized > RecoverSafe for & ' a T { }
161
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for * const T { }
162
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for * mut T { }
163
+ impl < ' a , T : RefRecoverSafe + ?Sized > RecoverSafe for & ' a T { }
164
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for * const T { }
165
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for * mut T { }
163
166
impl < T : RecoverSafe > RecoverSafe for Unique < T > { }
164
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Shared < T > { }
167
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Shared < T > { }
165
168
impl < T : ?Sized > RecoverSafe for Mutex < T > { }
166
169
impl < T : ?Sized > RecoverSafe for RwLock < T > { }
167
170
impl < T > RecoverSafe for AssertRecoverSafe < T > { }
168
171
169
172
// not covered via the Shared impl above b/c the inner contents use
170
173
// Cell/AtomicUsize, but the usage here is recover safe so we can lift the
171
174
// impl up one level to Arc/Rc itself
172
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Rc < T > { }
173
- impl < T : NoUnsafeCell + ?Sized > RecoverSafe for Arc < T > { }
175
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Rc < T > { }
176
+ impl < T : RefRecoverSafe + ?Sized > RecoverSafe for Arc < T > { }
174
177
175
- // Pretty simple implementations for the `NoUnsafeCell` marker trait, basically
176
- // just saying that this is a marker trait and `UnsafeCell` is the only thing
177
- // which doesn't implement it (which then transitively applies to everything
178
- // else.
179
- impl NoUnsafeCell for .. { }
180
- impl < T : ?Sized > !NoUnsafeCell for UnsafeCell < T > { }
178
+ // Pretty simple implementations for the `RefRecoverSafe` marker trait,
179
+ // basically just saying that this is a marker trait and `UnsafeCell` is the
180
+ // only thing which doesn't implement it (which then transitively applies to
181
+ // everything else.
182
+ impl RefRecoverSafe for .. { }
183
+ impl < T : ?Sized > !RefRecoverSafe for UnsafeCell < T > { }
184
+ impl < T > RefRecoverSafe for AssertRecoverSafe < T > { }
181
185
182
186
impl < T > AssertRecoverSafe < T > {
183
187
/// Creates a new `AssertRecoverSafe` wrapper around the provided type.
0 commit comments