11//! A set of high-level utility fixture methods to use in tests.
2- use std::{mem, str::FromStr, sync};
2+ use std::{any::TypeId, mem, str::FromStr, sync};
33
44use base_db::{
55 Crate, CrateDisplayName, CrateGraphBuilder, CrateName, CrateOrigin, CrateWorkspaceData,
@@ -677,6 +677,10 @@ impl ProcMacroExpander for IdentityProcMacroExpander {
677677 ) -> Result<TopSubtree, ProcMacroExpansionError> {
678678 Ok(subtree.clone())
679679 }
680+
681+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
682+ other.type_id() == TypeId::of::<Self>()
683+ }
680684}
681685
682686// Expands to a macro_rules! macro, for issue #18089.
@@ -708,6 +712,10 @@ impl ProcMacroExpander for Issue18089ProcMacroExpander {
708712 #subtree
709713 })
710714 }
715+
716+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
717+ other.type_id() == TypeId::of::<Self>()
718+ }
711719}
712720
713721// Pastes the attribute input as its output
@@ -728,6 +736,10 @@ impl ProcMacroExpander for AttributeInputReplaceProcMacroExpander {
728736 .cloned()
729737 .ok_or_else(|| ProcMacroExpansionError::Panic("Expected attribute input".into()))
730738 }
739+
740+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
741+ other.type_id() == TypeId::of::<Self>()
742+ }
731743}
732744
733745#[derive(Debug)]
@@ -759,6 +771,10 @@ impl ProcMacroExpander for Issue18840ProcMacroExpander {
759771 top_subtree_delimiter_mut.close = def_site;
760772 Ok(result)
761773 }
774+
775+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
776+ other.type_id() == TypeId::of::<Self>()
777+ }
762778}
763779
764780#[derive(Debug)]
@@ -790,6 +806,10 @@ impl ProcMacroExpander for MirrorProcMacroExpander {
790806 traverse(&mut builder, input.iter());
791807 Ok(builder.build())
792808 }
809+
810+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
811+ other.type_id() == TypeId::of::<Self>()
812+ }
793813}
794814
795815// Replaces every literal with an empty string literal and every identifier with its first letter,
@@ -830,6 +850,10 @@ impl ProcMacroExpander for ShortenProcMacroExpander {
830850 }
831851 }
832852 }
853+
854+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
855+ other.type_id() == TypeId::of::<Self>()
856+ }
833857}
834858
835859// Reads ident type within string quotes, for issue #17479.
@@ -855,6 +879,10 @@ impl ProcMacroExpander for Issue17479ProcMacroExpander {
855879 #symbol()
856880 })
857881 }
882+
883+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
884+ other.type_id() == TypeId::of::<Self>()
885+ }
858886}
859887
860888// Reads ident type within string quotes, for issue #17479.
@@ -906,6 +934,10 @@ impl ProcMacroExpander for Issue18898ProcMacroExpander {
906934 }
907935 })
908936 }
937+
938+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
939+ other.type_id() == TypeId::of::<Self>()
940+ }
909941}
910942
911943// Reads ident type within string quotes, for issue #17479.
@@ -933,6 +965,10 @@ impl ProcMacroExpander for DisallowCfgProcMacroExpander {
933965 }
934966 Ok(subtree.clone())
935967 }
968+
969+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
970+ other.type_id() == TypeId::of::<Self>()
971+ }
936972}
937973
938974// Generates a new type by adding a suffix to the original name
@@ -987,4 +1023,8 @@ impl ProcMacroExpander for GenerateSuffixedTypeProcMacroExpander {
9871023
9881024 Ok(ret)
9891025 }
1026+
1027+ fn eq_dyn(&self, other: &dyn ProcMacroExpander) -> bool {
1028+ other.type_id() == TypeId::of::<Self>()
1029+ }
9901030}
0 commit comments