From b9746ce03901fc39707c8c2d0405caf5384b4e97 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Fri, 3 Mar 2023 10:14:57 +0800 Subject: introduce `DynSend` and `DynSync` auto trait --- compiler/rustc_data_structures/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_data_structures/src/lib.rs') diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 004017ec5f3..f543e0d4a7a 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -26,9 +26,11 @@ #![feature(test)] #![feature(thread_id_value)] #![feature(vec_into_raw_parts)] +#![feature(allocator_api)] #![feature(get_mut_unchecked)] #![feature(lint_reasons)] -#![feature(unwrap_infallible)] +#![feature(unwrap_infallible)]#![feature(const_mut_refs)] +#![feature(const_trait_impl)] #![feature(strict_provenance)] #![feature(ptr_alignment_type)] #![feature(macro_metavar_expr)] @@ -77,6 +79,7 @@ pub mod sorted_map; pub mod stable_hasher; mod atomic_ref; pub mod fingerprint; +pub mod marker; pub mod profiling; pub mod sharded; pub mod stack; -- cgit 1.4.1-3-g733a5 From bffccddac3470f68efe15a3e81257869be562568 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Mon, 10 Apr 2023 09:53:50 +0800 Subject: correct import of owned_slice --- compiler/rustc_data_structures/src/lib.rs | 3 ++- compiler/rustc_data_structures/src/marker.rs | 12 ++---------- compiler/rustc_data_structures/src/owned_slice/tests.rs | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) (limited to 'compiler/rustc_data_structures/src/lib.rs') diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index f543e0d4a7a..579f54c5f71 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -29,7 +29,8 @@ #![feature(allocator_api)] #![feature(get_mut_unchecked)] #![feature(lint_reasons)] -#![feature(unwrap_infallible)]#![feature(const_mut_refs)] +#![feature(unwrap_infallible)] +#![feature(const_mut_refs)] #![feature(const_trait_impl)] #![feature(strict_provenance)] #![feature(ptr_alignment_type)] diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index 6dad2bac58a..e23a10839ee 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -72,6 +72,7 @@ cfg_if!( [rustc_arena::DroplessArena] [crate::memmap::Mmap] [crate::profiling::SelfProfiler] + [crate::owned_slice::OwnedSlice] ); macro_rules! impl_dyn_send { @@ -98,11 +99,6 @@ cfg_if!( [indexmap::IndexMap where K: DynSend, V: DynSend, S: DynSend] [thin_vec::ThinVec where T: DynSend] [smallvec::SmallVec where A: smallvec::Array + DynSend] - - // We use `Send` here, since they are only used in `Send` situations now. - // In this case we don't need copy or change the codes in `crate::owning_ref`. - [crate::owning_ref::OwningRef where O: Send, T: ?Sized + Send] - [crate::owning_ref::OwningRefMut where O: Send, T: ?Sized + Send] ); macro_rules! impls_dyn_sync_neg { @@ -154,6 +150,7 @@ cfg_if!( [jobserver_crate::Client] [crate::memmap::Mmap] [crate::profiling::SelfProfiler] + [crate::owned_slice::OwnedSlice] ); macro_rules! impl_dyn_sync { @@ -184,11 +181,6 @@ cfg_if!( [indexmap::IndexMap where K: DynSync, V: DynSync, S: DynSync] [smallvec::SmallVec where A: smallvec::Array + DynSync] [thin_vec::ThinVec where T: DynSync] - - // We use `Sync` here, since they are only used in `Sync` situations now. - // In this case we don't need copy or change the codes in `crate::owning_ref`. - [crate::owning_ref::OwningRef where O: Sync, T: ?Sized + Sync] - [crate::owning_ref::OwningRefMut where O: Sync, T: ?Sized + Sync] ); } ); diff --git a/compiler/rustc_data_structures/src/owned_slice/tests.rs b/compiler/rustc_data_structures/src/owned_slice/tests.rs index e715fb55362..e151b8c2de0 100644 --- a/compiler/rustc_data_structures/src/owned_slice/tests.rs +++ b/compiler/rustc_data_structures/src/owned_slice/tests.rs @@ -69,6 +69,6 @@ fn drop_drops() { #[test] fn send_sync() { - crate::sync::assert_send::(); - crate::sync::assert_sync::(); + crate::sync::assert_dyn_send::(); + crate::sync::assert_dyn_sync::(); } -- cgit 1.4.1-3-g733a5 From d7e3e5bede187d113fa01c4d8b8c16a2bd4f721c Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Sat, 6 May 2023 10:23:51 +0800 Subject: add `DynSend / DynSync` for `CopyTaggedPtr` --- compiler/rustc_data_structures/src/lib.rs | 2 -- compiler/rustc_data_structures/src/marker.rs | 11 ++++++++--- compiler/rustc_middle/src/ty/query.rs | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_data_structures/src/lib.rs') diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 579f54c5f71..5b9b0e106d2 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -30,8 +30,6 @@ #![feature(get_mut_unchecked)] #![feature(lint_reasons)] #![feature(unwrap_infallible)] -#![feature(const_mut_refs)] -#![feature(const_trait_impl)] #![feature(strict_provenance)] #![feature(ptr_alignment_type)] #![feature(macro_metavar_expr)] diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index e23a10839ee..f8c06f9a814 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -94,6 +94,7 @@ cfg_if!( [Box where T: ?Sized + DynSend, A: std::alloc::Allocator + DynSend] [crate::sync::Lock where T: DynSend] [crate::sync::RwLock where T: DynSend] + [crate::tagged_ptr::CopyTaggedPtr where P: Send + crate::tagged_ptr::Pointer, T: Send + crate::tagged_ptr::Tag, const CP: bool] [rustc_arena::TypedArena where T: DynSend] [indexmap::IndexSet where V: DynSend, S: DynSend] [indexmap::IndexMap where K: DynSend, V: DynSend, S: DynSend] @@ -175,6 +176,7 @@ cfg_if!( [crate::sync::OneThread where T] [crate::sync::WorkerLocal where T: DynSend] [crate::intern::Interned<'a, T> where 'a, T: DynSync] + [crate::tagged_ptr::CopyTaggedPtr where P: Sync + crate::tagged_ptr::Pointer, T: Sync + crate::tagged_ptr::Tag, const CP: bool] [parking_lot::lock_api::Mutex where R: DynSync, T: ?Sized + DynSend] [parking_lot::lock_api::RwLock where R: DynSync, T: ?Sized + DynSend + DynSync] [indexmap::IndexSet where V: DynSync, S: DynSync] @@ -218,9 +220,10 @@ unsafe impl Send for FromDyn {} #[cfg(parallel_compiler)] unsafe impl Sync for FromDyn {} -impl const std::ops::Deref for FromDyn { +impl std::ops::Deref for FromDyn { type Target = T; + #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } @@ -237,15 +240,17 @@ unsafe impl DynSend for IntoDynSyncSend {} #[cfg(parallel_compiler)] unsafe impl DynSync for IntoDynSyncSend {} -impl const std::ops::Deref for IntoDynSyncSend { +impl std::ops::Deref for IntoDynSyncSend { type Target = T; + #[inline(always)] fn deref(&self) -> &T { &self.0 } } -impl const std::ops::DerefMut for IntoDynSyncSend { +impl std::ops::DerefMut for IntoDynSyncSend { + #[inline(always)] fn deref_mut(&mut self) -> &mut T { &mut self.0 } diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 1d09a62ca17..07d47cae5ee 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -52,8 +52,9 @@ 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::WorkerLocal; -use rustc_data_structures::sync::{self, Lrc}; +use rustc_data_structures::sync::AtomicU64; +use rustc_data_structures::sync::Lrc; +use rustc_data_structures::sync::WorkerLocal; use rustc_data_structures::unord::UnordSet; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; -- cgit 1.4.1-3-g733a5