From afd83e0686512ad2678a2b0bad3b1421692a28bf Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 1 Apr 2021 22:24:40 +0200 Subject: Remove unnecessary region, relax `Sized` bounds --- crates/hir_def/src/intern.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'crates/hir_def/src/intern.rs') diff --git a/crates/hir_def/src/intern.rs b/crates/hir_def/src/intern.rs index 4d8fbd324..18c8ab246 100644 --- a/crates/hir_def/src/intern.rs +++ b/crates/hir_def/src/intern.rs @@ -16,7 +16,7 @@ use rustc_hash::FxHasher; type InternMap = DashMap, (), BuildHasherDefault>; #[derive(Hash)] -pub struct Interned { +pub struct Interned { arc: Arc, } @@ -52,7 +52,7 @@ impl Interned { } } -impl Drop for Interned { +impl Drop for Interned { fn drop(&mut self) { // When the last `Ref` is dropped, remove the object from the global map. if Arc::strong_count(&self.arc) == 2 { @@ -83,23 +83,23 @@ impl Drop for Interned { } /// Compares interned `Ref`s using pointer equality. -impl PartialEq for Interned { +impl PartialEq for Interned { #[inline] fn eq(&self, other: &Self) -> bool { Arc::ptr_eq(&self.arc, &other.arc) } } -impl Eq for Interned {} +impl Eq for Interned {} -impl AsRef for Interned { +impl AsRef for Interned { #[inline] fn as_ref(&self) -> &T { &self.arc } } -impl Deref for Interned { +impl Deref for Interned { type Target = T; #[inline] @@ -108,40 +108,38 @@ impl Deref for Interned { } } -impl Clone for Interned { +impl Clone for Interned { fn clone(&self) -> Self { Self { arc: self.arc.clone() } } } -impl Debug for Interned { +impl Debug for Interned { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (*self.arc).fmt(f) } } -pub struct InternStorage { +pub struct InternStorage { map: OnceCell>, } -impl InternStorage { +impl InternStorage { pub const fn new() -> Self { Self { map: OnceCell::new() } } } -impl InternStorage { +impl InternStorage { fn get(&self) -> &InternMap { self.map.get_or_init(DashMap::default) } } -pub trait Internable: Hash + Eq + Sized + 'static { +pub trait Internable: Hash + Eq + 'static { fn storage() -> &'static InternStorage; } -// region:`Internable` implementations - macro_rules! impl_internable { ( $($t:ty),+ $(,)? ) => { $( impl Internable for $t { @@ -154,5 +152,3 @@ macro_rules! impl_internable { } impl_internable!(crate::type_ref::TypeRef, crate::type_ref::TraitRef, crate::path::ModPath); - -// endregion -- cgit v1.2.3