File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ use rustc_data_structures::profiling::SelfProfilerRef;
39
39
use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
40
40
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
41
41
use rustc_data_structures:: steal:: Steal ;
42
+ #[ cfg( parallel_compiler) ]
43
+ use rustc_data_structures:: sync:: { self , DynSend , DynSync } ;
42
44
use rustc_data_structures:: sync:: { FreezeReadGuard , Lock , WorkerLocal } ;
43
45
use rustc_data_structures:: unord:: UnordSet ;
44
46
use rustc_errors:: {
@@ -517,6 +519,16 @@ pub struct TyCtxt<'tcx> {
517
519
gcx : & ' tcx GlobalCtxt < ' tcx > ,
518
520
}
519
521
522
+ // Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution.
523
+ #[ cfg( parallel_compiler) ]
524
+ unsafe impl DynSend for TyCtxt < ' _ > { }
525
+ #[ cfg( parallel_compiler) ]
526
+ unsafe impl DynSync for TyCtxt < ' _ > { }
527
+ fn _assert_tcx_fields ( ) {
528
+ sync:: assert_dyn_sync :: < & ' _ GlobalCtxt < ' _ > > ( ) ;
529
+ sync:: assert_dyn_send :: < & ' _ GlobalCtxt < ' _ > > ( ) ;
530
+ }
531
+
520
532
impl < ' tcx > Deref for TyCtxt < ' tcx > {
521
533
type Target = & ' tcx GlobalCtxt < ' tcx > ;
522
534
#[ inline( always) ]
You can’t perform that action at this time.
0 commit comments