@@ -9,15 +9,13 @@ use std::mem;
99use syntax:: ast;
1010use syntax:: feature_gate;
1111use syntax:: token;
12- use syntax:: tokenstream;
1312use syntax_pos:: SourceFile ;
1413
1514use crate :: hir:: def_id:: { DefId , CrateNum , CRATE_DEF_INDEX } ;
1615
1716use smallvec:: SmallVec ;
1817use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1918
20- impl < ' ctx > syntax:: StableHashingContextLike for StableHashingContext < ' ctx > { }
2119impl < ' ctx > rustc_target:: StableHashingContextLike for StableHashingContext < ' ctx > { }
2220
2321impl_stable_hash_for_spanned ! ( :: syntax:: ast:: LitKind ) ;
@@ -47,11 +45,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
4745 }
4846}
4947
50- impl_stable_hash_for ! ( struct :: syntax:: ast:: AttrItem {
51- path,
52- tokens,
53- } ) ;
54-
5548impl < ' a > HashStable < StableHashingContext < ' a > > for ast:: Attribute {
5649 fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
5750 // Make sure that these have been filtered out.
@@ -69,38 +62,10 @@ impl<'a> HashStable<StableHashingContext<'a>> for ast::Attribute {
6962 }
7063}
7164
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 {
10469 token:: Eq |
10570 token:: Lt |
10671 token:: Le |
@@ -141,30 +106,25 @@ impl<'a> HashStable<StableHashingContext<'a>> for token::TokenKind {
141106 token:: CloseDelim ( delim_token) => {
142107 std_hash:: Hash :: hash ( & delim_token, hasher) ;
143108 }
144- token:: Literal ( lit) => lit. hash_stable ( hcx , hasher) ,
109+ token:: Literal ( lit) => lit. hash_stable ( self , hasher) ,
145110
146111 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) ;
149114 }
150- token:: Lifetime ( name) => name. hash_stable ( hcx , hasher) ,
115+ token:: Lifetime ( name) => name. hash_stable ( self , hasher) ,
151116
152117 token:: Interpolated ( _) => {
153118 bug ! ( "interpolated tokens should not be present in the HIR" )
154119 }
155120
156121 token:: DocComment ( val) |
157122 token:: Shebang ( val) |
158- token:: Unknown ( val) => val. hash_stable ( hcx , hasher) ,
123+ token:: Unknown ( val) => val. hash_stable ( self , hasher) ,
159124 }
160125 }
161126}
162127
163- impl_stable_hash_for ! ( struct token:: Token {
164- kind,
165- span
166- } ) ;
167-
168128impl_stable_hash_for ! ( enum :: syntax:: ast:: NestedMetaItem {
169129 MetaItem ( meta_item) ,
170130 Literal ( lit)
0 commit comments