diff options
| author | bors <bors@rust-lang.org> | 2024-01-20 13:18:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-20 13:18:33 +0000 |
| commit | 6745c6000aa037c14bf4359c5cb56d4c657bfe3c (patch) | |
| tree | b6af32ed9082bc7785bb69c0cb14be3f240e3838 /compiler/rustc_data_structures/src | |
| parent | 227abacaef5981c2bee0fe6f087d5dbac8b84e77 (diff) | |
| parent | 63446d00ee2005125b1e4a7c3f00547101065709 (diff) | |
| download | rust-6745c6000aa037c14bf4359c5cb56d4c657bfe3c.tar.gz rust-6745c6000aa037c14bf4359c5cb56d4c657bfe3c.zip | |
Auto merge of #116185 - Zoxc:rem-one-thread, r=cjgillot
Remove `OneThread` This removes `OneThread` by switching `incr_comp_session` over to `RwLock`.
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/marker.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/sync.rs | 56 |
2 files changed, 0 insertions, 57 deletions
diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index 266e54604a6..a9ccfbed411 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -177,7 +177,6 @@ cfg_match! { [Vec<T, A> where T: DynSync, A: std::alloc::Allocator + DynSync] [Box<T, A> where T: ?Sized + DynSync, A: std::alloc::Allocator + DynSync] [crate::sync::RwLock<T> where T: DynSend + DynSync] - [crate::sync::OneThread<T> where T] [crate::sync::WorkerLocal<T> where T: DynSend] [crate::intern::Interned<'a, T> where 'a, T: DynSync] [crate::tagged_ptr::CopyTaggedPtr<P, T, CP> where P: Sync + crate::tagged_ptr::Pointer, T: Sync + crate::tagged_ptr::Tag, const CP: bool] diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 48edfba8da0..adcb6ceaebf 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -43,7 +43,6 @@ pub use crate::marker::*; use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; -use std::ops::{Deref, DerefMut}; mod lock; pub use lock::{Lock, LockGuard, Mode}; @@ -309,8 +308,6 @@ cfg_match! { use parking_lot::RwLock as InnerRwLock; - use std::thread; - /// This makes locks panic if they are already held. /// It is only useful when you are running in a single thread const ERROR_CHECKING: bool = false; @@ -445,56 +442,3 @@ impl<T: Clone> Clone for RwLock<T> { RwLock::new(self.borrow().clone()) } } - -/// A type which only allows its inner value to be used in one thread. -/// It will panic if it is used on multiple threads. -#[derive(Debug)] -pub struct OneThread<T> { - #[cfg(parallel_compiler)] - thread: thread::ThreadId, - inner: T, -} - -#[cfg(parallel_compiler)] -unsafe impl<T> std::marker::Sync for OneThread<T> {} -#[cfg(parallel_compiler)] -unsafe impl<T> std::marker::Send for OneThread<T> {} - -impl<T> OneThread<T> { - #[inline(always)] - fn check(&self) { - #[cfg(parallel_compiler)] - assert_eq!(thread::current().id(), self.thread); - } - - #[inline(always)] - pub fn new(inner: T) -> Self { - OneThread { - #[cfg(parallel_compiler)] - thread: thread::current().id(), - inner, - } - } - - #[inline(always)] - pub fn into_inner(value: Self) -> T { - value.check(); - value.inner - } -} - -impl<T> Deref for OneThread<T> { - type Target = T; - - fn deref(&self) -> &T { - self.check(); - &self.inner - } -} - -impl<T> DerefMut for OneThread<T> { - fn deref_mut(&mut self) -> &mut T { - self.check(); - &mut self.inner - } -} |
