@@ -16,14 +16,13 @@ use rustc_span::{Ident, Symbol};
1616use crate :: ast;
1717use crate :: util:: case:: Case ;
1818
19- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
19+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
2020pub enum CommentKind {
2121 Line ,
2222 Block ,
2323}
2424
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 ) ]
2726pub enum InvisibleOrigin {
2827 // From the expansion of a metavariable in a declarative macro.
2928 MetaVar ( MetaVarKind ) ,
@@ -45,20 +44,6 @@ impl InvisibleOrigin {
4544 }
4645}
4746
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-
6247/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
6348#[ derive( Debug , Copy , Clone , PartialEq , Eq , Encodable , Decodable , Hash , HashStable_Generic ) ]
6449pub enum MetaVarKind {
@@ -114,7 +99,7 @@ impl fmt::Display for MetaVarKind {
11499/// Describes how a sequence of token trees is delimited.
115100/// Cannot use `proc_macro::Delimiter` directly because this
116101/// 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 ) ]
118103pub enum Delimiter {
119104 /// `( ... )`
120105 Parenthesis ,
@@ -142,7 +127,8 @@ impl Delimiter {
142127 }
143128 }
144129
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.
146132 pub fn eq_ignoring_invisible_origin ( & self , other : & Delimiter ) -> bool {
147133 match ( self , other) {
148134 ( Delimiter :: Parenthesis , Delimiter :: Parenthesis ) => true ,
@@ -176,7 +162,7 @@ impl Delimiter {
176162// type. This means that float literals like `1f32` are classified by this type
177163// as `Int`. Only upon conversion to `ast::LitKind` will such a literal be
178164// 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 ) ]
180166pub enum LitKind {
181167 Bool , // AST only, must never appear in a `Token`
182168 Byte ,
@@ -193,7 +179,7 @@ pub enum LitKind {
193179}
194180
195181/// 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 ) ]
197183pub struct Lit {
198184 pub kind : LitKind ,
199185 pub symbol : Symbol ,
@@ -339,7 +325,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
339325 . contains ( & name)
340326}
341327
342- #[ derive( PartialEq , Encodable , Decodable , Debug , Copy , Clone , HashStable_Generic ) ]
328+ #[ derive( PartialEq , Eq , Encodable , Decodable , Hash , Debug , Copy , Clone , HashStable_Generic ) ]
343329pub enum IdentIsRaw {
344330 No ,
345331 Yes ,
@@ -366,7 +352,7 @@ impl From<bool> for IdentIsRaw {
366352 }
367353}
368354
369- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
355+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
370356pub enum TokenKind {
371357 /* Expression-operator symbols. */
372358 /// `=`
@@ -516,7 +502,7 @@ pub enum TokenKind {
516502 Eof ,
517503}
518504
519- #[ derive( Clone , Copy , PartialEq , Encodable , Decodable , Debug , HashStable_Generic ) ]
505+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Encodable , Decodable , Debug , HashStable_Generic ) ]
520506pub struct Token {
521507 pub kind : TokenKind ,
522508 pub span : Span ,
0 commit comments