From 375284fff09f8548e5bf733850743110276e8957 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 23 Feb 2020 18:48:38 +0100 Subject: clang-parser: remove some more unused API --- src/parser/clang/entities.rs | 79 ++++---------------------------------------- 1 file changed, 6 insertions(+), 73 deletions(-) (limited to 'src/parser/clang/entities.rs') diff --git a/src/parser/clang/entities.rs b/src/parser/clang/entities.rs index 7b98e88..e6fe59d 100644 --- a/src/parser/clang/entities.rs +++ b/src/parser/clang/entities.rs @@ -91,13 +91,6 @@ pub(super) struct Described { type DescribedDynEntity = Described; impl Described { - fn to_dyn(&self) -> DescribedRef { - DescribedRef { - description: &self.description, - entity: self.entity.to_dyn(), - } - } - #[allow(clippy::wrong_self_convention)] fn to_dyn_mut(&mut self) -> DescribedRefMut { DescribedRefMut { @@ -114,9 +107,9 @@ where type Error = Error; fn try_from(entity: clang::Entity<'a>) -> Result { - Ok(Described:: { + Ok(Described { description: entity.try_into()?, - entity: T::try_from(entity)?, + entity: entity.try_into()?, }) } } @@ -138,21 +131,13 @@ impl> From> for types::Entity { } } -#[derive(Debug, Clone)] -pub(super) struct DescribedRef<'a, T> { - pub description: &'a Description, - pub entity: T, -} - -type DescribedDynEntityRef<'d, 'e> = DescribedRef<'d, DynEntityRef<'e>>; - -#[derive(Debug, Clone)] -pub(super) struct DescribedRefMut<'a, T> { - pub description: &'a Description, +#[derive(Debug)] +pub(super) struct DescribedRefMut<'d, T> { + pub description: &'d mut Description, pub entity: T, } -type DescribedDynEntityRefMut<'a, 'b> = DescribedRefMut<'a, DynEntityRefMut<'b>>; +type DescribedDynEntityRefMut<'d, 'e> = DescribedRefMut<'d, DynEntityRefMut<'e>>; impl<'d, 'e, T: Entity> DescribedRefMut<'d, &'e mut T> { fn from_dyn_mut(dyn_entity: DescribedDynEntityRefMut<'d, 'e>) -> Option { @@ -166,19 +151,13 @@ impl<'d, 'e, T: Entity> DescribedRefMut<'d, &'e mut T> { pub(super) trait Entity: Traversable + KindName { const KIND: EntityKind; - fn from_dyn(dyn_entity: DynEntity) -> Option - where - Self: Sized; - fn from_dyn_ref(dyn_entity: DynEntityRef) -> Option<&Self>; fn from_dyn_mut(dyn_entity: DynEntityRefMut) -> Option<&mut Self>; fn into_dyn(self) -> DynEntity; - fn to_dyn(&self) -> DynEntityRef; fn to_dyn_mut(&mut self) -> DynEntityRefMut; } pub(super) trait Traversable { fn has_child_from_kind(&self, usr: &Usr, kind: EntityKind) -> bool; - fn get_child_from_kind(&self, usr: &Usr, kind: EntityKind) -> Option; fn get_mut_child_from_kind( &mut self, usr: &Usr, @@ -243,20 +222,6 @@ macro_rules! entity { impl Entity for $name { const KIND: EntityKind = EntityKind::$name; - fn from_dyn(dyn_entity: DynEntity) -> Option { - match dyn_entity { - DynEntity::$name(me) => Some(me), - _ => None, - } - } - - fn from_dyn_ref(dyn_entity: DynEntityRef) -> Option<&Self> { - match dyn_entity { - DynEntityRef::$name(me) => Some(me), - _ => None, - } - } - fn from_dyn_mut(dyn_entity: DynEntityRefMut) -> Option<&mut Self> { match dyn_entity { DynEntityRefMut::$name(me) => Some(me), @@ -268,10 +233,6 @@ macro_rules! entity { DynEntity::$name(self) } - fn to_dyn(&self) -> DynEntityRef { - DynEntityRef::$name(self) - } - fn to_dyn_mut(&mut self) -> DynEntityRefMut { DynEntityRefMut::$name(self) } @@ -288,22 +249,6 @@ macro_rules! entity { } } - #[allow(unused_variables, unreachable_patterns)] - fn get_child_from_kind( - &self, - usr: &Usr, - kind: EntityKind - ) -> Option { - match kind { - $($( - EntityKind::$child_type => { - self.$child_name.get(usr).map(Described::to_dyn) - } - )*)? - _ => None, - } - } - #[allow(unused_variables, unreachable_patterns)] fn get_mut_child_from_kind( &mut self, @@ -403,7 +348,6 @@ impl From for types::Entity { } } -// TODO: Probably remove NoParent in favor of the Error variant of Result #[derive(Debug)] pub(super) enum EntityEntry<'d, 'e, T> { Vacant { @@ -503,17 +447,6 @@ pub(super) enum DynEntity { TypeAlias(TypeAlias), } -#[derive(Debug, Clone, Copy)] -pub(super) enum DynEntityRef<'a> { - Namespace(&'a Namespace), - Variable(&'a Variable), - Struct(&'a Struct), - Function(&'a Function), - Enum(&'a Enum), - EnumConstant(&'a EnumConstant), - TypeAlias(&'a TypeAlias), -} - #[derive(Debug)] pub(super) enum DynEntityRefMut<'a> { Namespace(&'a mut Namespace), -- cgit v1.2.3