@@ -16,14 +16,13 @@ use rustc_span::{Ident, Symbol};
16
16
use crate :: ast;
17
17
use crate :: util:: case:: Case ;
18
18
19
- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
19
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
20
20
pub enum CommentKind {
21
21
Line ,
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 , Eq , Hash , 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 {
@@ -114,7 +99,7 @@ impl fmt::Display for MetaVarKind {
114
99
/// Describes how a sequence of token trees is delimited.
115
100
/// Cannot use `proc_macro::Delimiter` directly because this
116
101
/// structure should implement some additional traits.
117
- #[ derive( Copy , Clone , Debug , PartialEq , Encodable , Decodable , HashStable_Generic ) ]
102
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable , HashStable_Generic ) ]
118
103
pub enum Delimiter {
119
104
/// `( ... )`
120
105
Parenthesis ,
@@ -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 ,
@@ -176,7 +162,7 @@ impl Delimiter {
176
162
// type. This means that float literals like `1f32` are classified by this type
177
163
// as `Int`. Only upon conversion to `ast::LitKind` will such a literal be
178
164
// given the `Float` kind.
179
- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
165
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
180
166
pub enum LitKind {
181
167
Bool , // AST only, must never appear in a `Token`
182
168
Byte ,
@@ -193,7 +179,7 @@ pub enum LitKind {
193
179
}
194
180
195
181
/// A literal token.
196
- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
182
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
197
183
pub struct Lit {
198
184
pub kind : LitKind ,
199
185
pub symbol : Symbol ,
@@ -339,7 +325,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
339
325
. contains ( & name)
340
326
}
341
327
342
- #[ derive( PartialEq , Encodable , Decodable , Debug , Copy , Clone , HashStable_Generic ) ]
328
+ #[ derive( PartialEq , Eq , Encodable , Decodable , Hash , Debug , Copy , Clone , HashStable_Generic ) ]
343
329
pub enum IdentIsRaw {
344
330
No ,
345
331
Yes ,
@@ -366,7 +352,7 @@ impl From<bool> for IdentIsRaw {
366
352
}
367
353
}
368
354
369
- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
355
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
370
356
pub enum TokenKind {
371
357
/* Expression-operator symbols. */
372
358
/// `=`
@@ -516,7 +502,7 @@ pub enum TokenKind {
516
502
Eof ,
517
503
}
518
504
519
- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
505
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
520
506
pub struct Token {
521
507
pub kind : TokenKind ,
522
508
pub span : Span ,
0 commit comments