diff options
| author | bors <bors@rust-lang.org> | 2023-12-08 22:14:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-08 22:14:13 +0000 |
| commit | 2d2f1b2099a9cf10d4300042f5ea15a65a203dae (patch) | |
| tree | 290ec19de86c44b7f064919e973fce71d08d93b9 | |
| parent | f967532a47eb728ada44473a5c4c2eca1a45fe30 (diff) | |
| parent | 365aaa8011c6a0603506d20dcc30117555f6a981 (diff) | |
| download | rust-2d2f1b2099a9cf10d4300042f5ea15a65a203dae.tar.gz rust-2d2f1b2099a9cf10d4300042f5ea15a65a203dae.zip | |
Auto merge of #117681 - Zoxc:tcx-sync, r=compiler-errors
Explicitly implement `DynSync` and `DynSend` for `TyCtxt` This is an attempt to short circuit trait resolution. It should get a perf run for bootstrap impact.
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 6ebfe778e7f..a1caa773b3b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -39,7 +39,9 @@ use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; -use rustc_data_structures::sync::{FreezeReadGuard, Lock, WorkerLocal}; +use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal}; +#[cfg(parallel_compiler)] +use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::unord::UnordSet; use rustc_errors::{ DecorateLint, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, MultiSpan, @@ -553,6 +555,16 @@ pub struct TyCtxt<'tcx> { gcx: &'tcx GlobalCtxt<'tcx>, } +// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. +#[cfg(parallel_compiler)] +unsafe impl DynSend for TyCtxt<'_> {} +#[cfg(parallel_compiler)] +unsafe impl DynSync for TyCtxt<'_> {} +fn _assert_tcx_fields() { + sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>(); + sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>(); +} + impl<'tcx> Deref for TyCtxt<'tcx> { type Target = &'tcx GlobalCtxt<'tcx>; #[inline(always)] |
