diff options
| author | SparrowLii <liyuan179@huawei.com> | 2023-03-03 10:14:57 +0800 |
|---|---|---|
| committer | SparrowLii <liyuan179@huawei.com> | 2023-05-06 09:34:18 +0800 |
| commit | b9746ce03901fc39707c8c2d0405caf5384b4e97 (patch) | |
| tree | 64ccb0f53279ed73da3b25f09d55029c9ae81323 /compiler/rustc_middle/src/ty | |
| parent | 963e5c0eff171160238dc2a2c0ba7a1912fada67 (diff) | |
| download | rust-b9746ce03901fc39707c8c2d0405caf5384b4e97.tar.gz rust-b9746ce03901fc39707c8c2d0405caf5384b4e97.zip | |
introduce `DynSend` and `DynSync` auto trait
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context/tls.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/list.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/query.rs | 5 |
4 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index c62254cd79c..f34de7d838e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -496,7 +496,7 @@ pub struct GlobalCtxt<'tcx> { /// /// FIXME(Centril): consider `dyn LintStoreMarker` once /// we can upcast to `Any` for some additional type safety. - pub lint_store: Lrc<dyn Any + sync::Sync + sync::Send>, + pub lint_store: Lrc<dyn Any + sync::DynSync + sync::DynSend>, pub dep_graph: DepGraph, @@ -648,7 +648,7 @@ impl<'tcx> TyCtxt<'tcx> { /// reference to the context, to allow formatting values that need it. pub fn create_global_ctxt( s: &'tcx Session, - lint_store: Lrc<dyn Any + sync::Send + sync::Sync>, + lint_store: Lrc<dyn Any + sync::DynSend + sync::DynSync>, arena: &'tcx WorkerLocal<Arena<'tcx>>, hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>, untracked: Untracked, diff --git a/compiler/rustc_middle/src/ty/context/tls.rs b/compiler/rustc_middle/src/ty/context/tls.rs index fb0d909307e..bf9806f6406 100644 --- a/compiler/rustc_middle/src/ty/context/tls.rs +++ b/compiler/rustc_middle/src/ty/context/tls.rs @@ -94,8 +94,8 @@ where f(None) } else { // We could get an `ImplicitCtxt` pointer from another thread. - // Ensure that `ImplicitCtxt` is `Sync`. - sync::assert_sync::<ImplicitCtxt<'_, '_>>(); + // Ensure that `ImplicitCtxt` is `DynSync`. + sync::assert_dyn_sync::<ImplicitCtxt<'_, '_>>(); unsafe { f(Some(downcast(context))) } } diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 30f036e471c..8f99a051328 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -199,6 +199,12 @@ impl<'a, T: Copy> IntoIterator for &'a List<T> { unsafe impl<T: Sync> Sync for List<T> {} +// We need this since `List` uses extern type `OpaqueListContents` +#[cfg(parallel_compiler)] +use rustc_data_structures::sync::DynSync; +#[cfg(parallel_compiler)] +unsafe impl<T: DynSync> DynSync for List<T> {} + // Safety: // Layouts of `Equivalent<T>` and `List<T>` are the same, modulo opaque tail, // thus aligns of `Equivalent<T>` and `List<T>` must be the same. diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 07d47cae5ee..1d09a62ca17 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -52,9 +52,8 @@ use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; -use rustc_data_structures::sync::AtomicU64; -use rustc_data_structures::sync::Lrc; -use rustc_data_structures::sync::WorkerLocal; +use rustc_data_structures::sync::AtomicU64;use rustc_data_structures::sync::WorkerLocal; +use rustc_data_structures::sync::{self, Lrc}; use rustc_data_structures::unord::UnordSet; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; |
