@@ -9,15 +9,13 @@ use std::mem;
9
9
use syntax:: ast;
10
10
use syntax:: feature_gate;
11
11
use syntax:: token;
12
- use syntax:: tokenstream;
13
12
use syntax_pos:: SourceFile ;
14
13
15
14
use crate :: hir:: def_id:: { DefId , CrateNum , CRATE_DEF_INDEX } ;
16
15
17
16
use smallvec:: SmallVec ;
18
17
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
19
18
20
- impl < ' ctx > syntax:: StableHashingContextLike for StableHashingContext < ' ctx > { }
21
19
impl < ' ctx > rustc_target:: StableHashingContextLike for StableHashingContext < ' ctx > { }
22
20
23
21
impl_stable_hash_for_spanned ! ( :: syntax:: ast:: LitKind ) ;
@@ -47,11 +45,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
47
45
}
48
46
}
49
47
50
- impl_stable_hash_for ! ( struct :: syntax:: ast:: AttrItem {
51
- path,
52
- tokens,
53
- } ) ;
54
-
55
48
impl < ' a > HashStable < StableHashingContext < ' a > > for ast:: Attribute {
56
49
fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
57
50
// Make sure that these have been filtered out.
@@ -69,38 +62,10 @@ impl<'a> HashStable<StableHashingContext<'a>> for ast::Attribute {
69
62
}
70
63
}
71
64
72
- impl < ' a > HashStable < StableHashingContext < ' a > >
73
- for tokenstream:: TokenTree {
74
- fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
75
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
76
- match * self {
77
- tokenstream:: TokenTree :: Token ( ref token) => {
78
- token. hash_stable ( hcx, hasher) ;
79
- }
80
- tokenstream:: TokenTree :: Delimited ( span, delim, ref tts) => {
81
- span. hash_stable ( hcx, hasher) ;
82
- std_hash:: Hash :: hash ( & delim, hasher) ;
83
- for sub_tt in tts. trees ( ) {
84
- sub_tt. hash_stable ( hcx, hasher) ;
85
- }
86
- }
87
- }
88
- }
89
- }
90
-
91
- impl < ' a > HashStable < StableHashingContext < ' a > >
92
- for tokenstream:: TokenStream {
93
- fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
94
- for sub_tt in self . trees ( ) {
95
- sub_tt. hash_stable ( hcx, hasher) ;
96
- }
97
- }
98
- }
99
-
100
- impl < ' a > HashStable < StableHashingContext < ' a > > for token:: TokenKind {
101
- fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
102
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
103
- match * self {
65
+ impl < ' ctx > syntax:: StableHashingContextLike for StableHashingContext < ' ctx > {
66
+ fn hash_stable_tokenkind ( & mut self , tokenkind : & token:: TokenKind , hasher : & mut StableHasher ) {
67
+ mem:: discriminant ( tokenkind) . hash_stable ( self , hasher) ;
68
+ match * tokenkind {
104
69
token:: Eq |
105
70
token:: Lt |
106
71
token:: Le |
@@ -141,30 +106,25 @@ impl<'a> HashStable<StableHashingContext<'a>> for token::TokenKind {
141
106
token:: CloseDelim ( delim_token) => {
142
107
std_hash:: Hash :: hash ( & delim_token, hasher) ;
143
108
}
144
- token:: Literal ( lit) => lit. hash_stable ( hcx , hasher) ,
109
+ token:: Literal ( lit) => lit. hash_stable ( self , hasher) ,
145
110
146
111
token:: Ident ( name, is_raw) => {
147
- name. hash_stable ( hcx , hasher) ;
148
- is_raw. hash_stable ( hcx , hasher) ;
112
+ name. hash_stable ( self , hasher) ;
113
+ is_raw. hash_stable ( self , hasher) ;
149
114
}
150
- token:: Lifetime ( name) => name. hash_stable ( hcx , hasher) ,
115
+ token:: Lifetime ( name) => name. hash_stable ( self , hasher) ,
151
116
152
117
token:: Interpolated ( _) => {
153
118
bug ! ( "interpolated tokens should not be present in the HIR" )
154
119
}
155
120
156
121
token:: DocComment ( val) |
157
122
token:: Shebang ( val) |
158
- token:: Unknown ( val) => val. hash_stable ( hcx , hasher) ,
123
+ token:: Unknown ( val) => val. hash_stable ( self , hasher) ,
159
124
}
160
125
}
161
126
}
162
127
163
- impl_stable_hash_for ! ( struct token:: Token {
164
- kind,
165
- span
166
- } ) ;
167
-
168
128
impl_stable_hash_for ! ( enum :: syntax:: ast:: NestedMetaItem {
169
129
MetaItem ( meta_item) ,
170
130
Literal ( lit)
0 commit comments