diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index c14665892b897..426d2c4034bd8 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -31,7 +31,6 @@ #![feature(unwrap_infallible)] #![feature(strict_provenance)] #![feature(ptr_alignment_type)] -#![feature(const_ptr_as_ref)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] #![deny(rustc::untranslatable_diagnostic)] diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 55217004fa437..534ba7f9c15e4 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -352,7 +352,7 @@ pub use std::sync::OnceLock as OnceCell; pub use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicUsize}; -pub type MTRef<'a, T> = &'a T; +pub type MTLockRef<'a, T> = &'a MTLock; #[derive(Debug, Default)] pub struct MTLock(Lock); @@ -422,9 +422,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 } @@ -564,23 +565,25 @@ pub struct LockGuard<'a, T> { marker: PhantomData<&'a mut T>, } -impl const Deref for LockGuard<'_, T> { +impl Deref for LockGuard<'_, T> { type Target = T; + #[inline(always)] fn deref(&self) -> &T { unsafe { &*self.lock.data.get() } } } -impl const DerefMut for LockGuard<'_, T> { +impl DerefMut for LockGuard<'_, T> { + #[inline(always)] fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.lock.data.get() } } } #[inline(never)] -unsafe fn unlock_mt(guard: &mut LockGuard<'_, T>) { - guard.lock.mutex.unlock() +fn unlock_mt(guard: &mut LockGuard<'_, T>) { + unsafe { guard.lock.mutex.unlock() } } impl<'a, T> Drop for LockGuard<'a, T> { @@ -590,7 +593,7 @@ impl<'a, T> Drop for LockGuard<'a, T> { debug_assert!(self.lock.borrow.get()); self.lock.borrow.set(false); } else { - unsafe { unlock_mt(self) } + unlock_mt(self) } } }