@@ -99,7 +99,7 @@ impl fmt::Display for MetaVarKind {
99
99
/// Describes how a sequence of token trees is delimited.
100
100
/// Cannot use `proc_macro::Delimiter` directly because this
101
101
/// 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 ) ]
103
103
pub enum Delimiter {
104
104
/// `( ... )`
105
105
Parenthesis ,
@@ -115,6 +115,22 @@ pub enum Delimiter {
115
115
Invisible ( InvisibleOrigin ) ,
116
116
}
117
117
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
+
118
134
impl Delimiter {
119
135
// Should the parser skip these delimiters? Only happens for certain kinds
120
136
// of invisible delimiters. Ideally this function will eventually disappear
0 commit comments