@@ -8,20 +8,20 @@ cfg_if!(
88 } else {
99 #[ rustc_on_unimplemented(
1010 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`"
1212 ) ]
1313 // This is an auto trait for types which can be sent across threads if `sync::is_dyn_thread_safe()`
1414 // 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.
1616 pub unsafe auto trait DynSend { }
1717
1818 #[ rustc_on_unimplemented(
1919 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`"
2121 ) ]
2222 // This is an auto trait for types which can be shared across threads if `sync::is_dyn_thread_safe()`
2323 // 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.
2525 pub unsafe auto trait DynSync { }
2626
2727 // Same with `Sync` and `Send`.
@@ -234,23 +234,26 @@ impl<T> const std::ops::Deref for FromDyn<T> {
234234 }
235235}
236236
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>)
237240#[ derive( Copy , Clone ) ]
238- pub struct IntoDyn < T : ?Sized > ( pub T ) ;
241+ pub struct IntoDynSyncSend < T : ?Sized > ( pub T ) ;
239242
240243#[ cfg( parallel_compiler) ]
241- unsafe impl < T : ?Sized + Send > DynSend for IntoDyn < T > { }
244+ unsafe impl < T : ?Sized + Send > DynSend for IntoDynSyncSend < T > { }
242245#[ cfg( parallel_compiler) ]
243- unsafe impl < T : ?Sized + Sync > DynSync for IntoDyn < T > { }
246+ unsafe impl < T : ?Sized + Sync > DynSync for IntoDynSyncSend < T > { }
244247
245- impl < T > const std:: ops:: Deref for IntoDyn < T > {
248+ impl < T > const std:: ops:: Deref for IntoDynSyncSend < T > {
246249 type Target = T ;
247250
248251 fn deref ( & self ) -> & T {
249252 & self . 0
250253 }
251254}
252255
253- impl < T > const std:: ops:: DerefMut for IntoDyn < T > {
256+ impl < T > const std:: ops:: DerefMut for IntoDynSyncSend < T > {
254257 fn deref_mut ( & mut self ) -> & mut T {
255258 & mut self . 0
256259 }
0 commit comments