From 44ca1a607a04a5eddf327b4ffbaa9c54c6b6b5d1 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Mon, 7 Oct 2024 20:27:39 -0700 Subject: [PATCH] remove unused AGCContext --- crates/fayalite/src/intern.rs | 128 ---------------------------------- 1 file changed, 128 deletions(-) diff --git a/crates/fayalite/src/intern.rs b/crates/fayalite/src/intern.rs index 9bd4d56..c38f26f 100644 --- a/crates/fayalite/src/intern.rs +++ b/crates/fayalite/src/intern.rs @@ -198,7 +198,6 @@ impl LazyInterned { pub trait InternedCompare { type InternedCompareKey: Ord + Hash; fn interned_compare_key_ref(this: &Self) -> Self::InternedCompareKey; - fn interned_compare_key_weak(this: &std::sync::Weak) -> Self::InternedCompareKey; } /// Warning: doesn't do what you want with `T = dyn Trait`, @@ -272,9 +271,6 @@ impl InternedCompare for T { fn interned_compare_key_ref(this: &Self) -> Self::InternedCompareKey { PtrEqWithMetadata(this) } - fn interned_compare_key_weak(this: &std::sync::Weak) -> Self::InternedCompareKey { - PtrEqWithMetadata(this.as_ptr()) - } } impl InternedCompare for [T] { @@ -282,9 +278,6 @@ impl InternedCompare for [T] { fn interned_compare_key_ref(this: &Self) -> Self::InternedCompareKey { PtrEqWithMetadata(this) } - fn interned_compare_key_weak(this: &std::sync::Weak) -> Self::InternedCompareKey { - PtrEqWithMetadata(this.as_ptr()) - } } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -295,9 +288,6 @@ impl InternedCompare for BitSlice { fn interned_compare_key_ref(this: &Self) -> Self::InternedCompareKey { BitSlicePtrEq(this.as_bitptr(), this.len()) } - fn interned_compare_key_weak(_this: &std::sync::Weak) -> Self::InternedCompareKey { - unreachable!("not currently implementable since Weak can't be constructed") - } } impl InternedCompare for str { @@ -305,9 +295,6 @@ impl InternedCompare for str { fn interned_compare_key_ref(this: &Self) -> Self::InternedCompareKey { PtrEqWithMetadata(this) } - fn interned_compare_key_weak(this: &std::sync::Weak) -> Self::InternedCompareKey { - PtrEqWithMetadata(this.as_ptr()) - } } pub trait InternContext: 'static + Send + Sync + Hash + Ord + fmt::Debug + Clone { @@ -408,121 +395,6 @@ impl BitSliceInternContext for GlobalContext { } } -#[derive(Clone)] -pub struct AGCContext(std::sync::Arc); - -impl AGCContext { - pub fn new() -> Self { - Self(std::sync::Arc::new(TypeIdMap::new())) - } -} - -impl Default for AGCContext { - fn default() -> Self { - Self::new() - } -} - -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct AGCContextId(*const ()); - -impl fmt::Debug for AGCContextId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } -} - -impl AGCContext { - pub fn id(&self) -> AGCContextId { - AGCContextId(std::sync::Arc::as_ptr(&self.0).cast()) - } -} - -impl Hash for AGCContext { - fn hash(&self, state: &mut H) { - self.id().hash(state); - } -} - -impl Ord for AGCContext { - fn cmp(&self, other: &Self) -> Ordering { - self.id().cmp(&other.id()) - } -} - -impl PartialOrd for AGCContext { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Eq for AGCContext {} - -impl PartialEq for AGCContext { - fn eq(&self, other: &Self) -> bool { - self.id().eq(&other.id()) - } -} - -impl fmt::Debug for AGCContext { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("AGCContext") - .field("id", &self.id()) - .finish_non_exhaustive() - } -} - -impl InternContext for AGCContext { - type InternedImpl = std::sync::Weak; - type InternedGuardImpl = std::sync::Arc; - type AllContextsAreIdentical = ConstBool; - - fn interned_compare_key( - v: &Self::InternedImpl, - ) -> T::InternedCompareKey { - T::interned_compare_key_weak(v) - } - fn guard( - v: &Self::InternedImpl, - ) -> Self::InternedGuardImpl { - v.upgrade().expect("expired") - } - fn try_guard( - v: &Self::InternedImpl, - ) -> Option> { - v.upgrade() - } - fn unguard( - v: &Self::InternedGuardImpl, - ) -> Self::InternedImpl { - std::sync::Arc::downgrade(v) - } - fn alloc_str(&self, value: Cow<'_, str>) -> Self::InternedGuardImpl { - match value { - Cow::Borrowed(value) => value.into(), - Cow::Owned(value) => value.into(), - } - } - fn alloc_slice( - &self, - value: Cow<'_, [T]>, - ) -> Self::InternedGuardImpl<[T]> { - match value { - Cow::Borrowed(value) => value.into(), - Cow::Owned(value) => value.into(), - } - } - fn alloc_sized( - &self, - value: Cow<'_, T>, - ) -> Self::InternedGuardImpl { - std::sync::Arc::new(value.into_owned()) - } - fn interner(&self) -> &Interner { - self.0.get_or_insert_default() - } -} - pub trait Intern: Any + Send + Sync { fn intern_with_ctx(&self, context: &C) -> Interned; fn intern_sized_with_ctx(self, context: &C) -> Interned