@@ -99,7 +99,7 @@ impl fmt::Display for MetaVarKind {
9999/// Describes how a sequence of token trees is delimited.
100100/// Cannot use `proc_macro::Delimiter` directly because this
101101/// structure should implement some additional traits.
102- #[ derive( Copy , Clone , Debug , PartialEq , Encodable , Decodable , HashStable_Generic ) ]
102+ #[ derive( Copy , Clone , Debug , Encodable , Decodable , HashStable_Generic ) ]
103103pub enum Delimiter {
104104 /// `( ... )`
105105 Parenthesis ,
@@ -115,6 +115,22 @@ pub enum Delimiter {
115115 Invisible ( InvisibleOrigin ) ,
116116}
117117
118+ impl PartialEq for Delimiter {
119+ fn eq ( & self , other : & Self ) -> bool {
120+ match ( self , other) {
121+ ( Delimiter :: Parenthesis , Delimiter :: Parenthesis ) => true ,
122+ ( Delimiter :: Brace , Delimiter :: Brace ) => true ,
123+ ( Delimiter :: Bracket , Delimiter :: Bracket ) => true ,
124+ ( Delimiter :: Invisible ( a) , Delimiter :: Invisible ( b) ) if a == b => {
125+ panic ! (
126+ "Comparing an invisible delimiter using PartialEq results in a different output than before"
127+ ) ;
128+ }
129+ _ => false ,
130+ }
131+ }
132+ }
133+
118134impl Delimiter {
119135 // Should the parser skip these delimiters? Only happens for certain kinds
120136 // of invisible delimiters. Ideally this function will eventually disappear
0 commit comments