@@ -8,20 +8,20 @@ cfg_if!(
8
8
} else {
9
9
#[ rustc_on_unimplemented(
10
10
message = "`{Self}` doesn't implement `DynSend`. \
11
- Add it to `rustc_data_structures::marker` or use `IntoDyn ` if it's already `Send`"
11
+ Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend ` if it's already `Send`"
12
12
) ]
13
13
// This is an auto trait for types which can be sent across threads if `sync::is_dyn_thread_safe()`
14
14
// is true. These types can be wrapped in a `FromDyn` to get a `Send` type. Wrapping a
15
- // `Send` type in `IntoDyn ` will create a `DynSend` type.
15
+ // `Send` type in `IntoDynSyncSend ` will create a `DynSend` type.
16
16
pub unsafe auto trait DynSend { }
17
17
18
18
#[ rustc_on_unimplemented(
19
19
message = "`{Self}` doesn't implement `DynSync`. \
20
- Add it to `rustc_data_structures::marker` or use `IntoDyn ` if it's already `Sync`"
20
+ Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend ` if it's already `Sync`"
21
21
) ]
22
22
// This is an auto trait for types which can be shared across threads if `sync::is_dyn_thread_safe()`
23
23
// is true. These types can be wrapped in a `FromDyn` to get a `Sync` type. Wrapping a
24
- // `Sync` type in `IntoDyn ` will create a `DynSync` type.
24
+ // `Sync` type in `IntoDynSyncSend ` will create a `DynSync` type.
25
25
pub unsafe auto trait DynSync { }
26
26
27
27
// Same with `Sync` and `Send`.
@@ -234,23 +234,26 @@ impl<T> const std::ops::Deref for FromDyn<T> {
234
234
}
235
235
}
236
236
237
+ // A wrapper to convert a struct that is already a `Send` or `Sync` into
238
+ // an instance of `DynSend` and `DynSync`, since the compiler cannot infer
239
+ // it automatically in some cases. (e.g. Box<dyn Send / Sync>)
237
240
#[ derive( Copy , Clone ) ]
238
- pub struct IntoDyn < T : ?Sized > ( pub T ) ;
241
+ pub struct IntoDynSyncSend < T : ?Sized > ( pub T ) ;
239
242
240
243
#[ cfg( parallel_compiler) ]
241
- unsafe impl < T : ?Sized + Send > DynSend for IntoDyn < T > { }
244
+ unsafe impl < T : ?Sized + Send > DynSend for IntoDynSyncSend < T > { }
242
245
#[ cfg( parallel_compiler) ]
243
- unsafe impl < T : ?Sized + Sync > DynSync for IntoDyn < T > { }
246
+ unsafe impl < T : ?Sized + Sync > DynSync for IntoDynSyncSend < T > { }
244
247
245
- impl < T > const std:: ops:: Deref for IntoDyn < T > {
248
+ impl < T > const std:: ops:: Deref for IntoDynSyncSend < T > {
246
249
type Target = T ;
247
250
248
251
fn deref ( & self ) -> & T {
249
252
& self . 0
250
253
}
251
254
}
252
255
253
- impl < T > const std:: ops:: DerefMut for IntoDyn < T > {
256
+ impl < T > const std:: ops:: DerefMut for IntoDynSyncSend < T > {
254
257
fn deref_mut ( & mut self ) -> & mut T {
255
258
& mut self . 0
256
259
}
0 commit comments