@@ -22,8 +22,7 @@ pub enum CommentKind {
22
22
Block ,
23
23
}
24
24
25
- // This type must not implement `Hash` due to the unusual `PartialEq` impl below.
26
- #[ derive( Copy , Clone , Debug , Encodable , Decodable , HashStable_Generic ) ]
25
+ #[ derive( Copy , Clone , PartialEq , Debug , Encodable , Decodable , HashStable_Generic ) ]
27
26
pub enum InvisibleOrigin {
28
27
// From the expansion of a metavariable in a declarative macro.
29
28
MetaVar ( MetaVarKind ) ,
@@ -45,20 +44,6 @@ impl InvisibleOrigin {
45
44
}
46
45
}
47
46
48
- impl PartialEq for InvisibleOrigin {
49
- #[ inline]
50
- fn eq ( & self , _other : & InvisibleOrigin ) -> bool {
51
- // When we had AST-based nonterminals we couldn't compare them, and the
52
- // old `Nonterminal` type had an `eq` that always returned false,
53
- // resulting in this restriction:
54
- // https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment
55
- // This `eq` emulates that behaviour. We could consider lifting this
56
- // restriction now but there are still cases involving invisible
57
- // delimiters that make it harder than it first appears.
58
- false
59
- }
60
- }
61
-
62
47
/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
63
48
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
64
49
pub enum MetaVarKind {
@@ -142,7 +127,8 @@ impl Delimiter {
142
127
}
143
128
}
144
129
145
- // This exists because `InvisibleOrigin`s should be compared. It is only used for assertions.
130
+ // This exists because `InvisibleOrigin`s should not be compared. It is only used for
131
+ // assertions.
146
132
pub fn eq_ignoring_invisible_origin ( & self , other : & Delimiter ) -> bool {
147
133
match ( self , other) {
148
134
( Delimiter :: Parenthesis , Delimiter :: Parenthesis ) => true ,
0 commit comments