22// pieces of AST and HIR. The resulting numbers are good approximations but not
33// completely accurate (some things might be counted twice, others missed).
44
5- use rustc:: hir;
5+ use rustc:: hir:: { self , HirId } ;
66use rustc:: hir:: intravisit as hir_visit;
77use rustc:: util:: common:: to_readable_str;
88use rustc:: util:: nodemap:: { FxHashMap , FxHashSet } ;
@@ -12,7 +12,7 @@ use syntax_pos::Span;
1212
1313#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
1414enum Id {
15- Node ( NodeId ) ,
15+ Node ( HirId ) ,
1616 Attr ( AttrId ) ,
1717 None ,
1818}
@@ -119,7 +119,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
119119 }
120120
121121 fn visit_item ( & mut self , i : & ' v hir:: Item ) {
122- self . record ( "Item" , Id :: Node ( i. id ) , i) ;
122+ self . record ( "Item" , Id :: Node ( i. hir_id ) , i) ;
123123 hir_visit:: walk_item ( self , i)
124124 }
125125
@@ -129,22 +129,22 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
129129 }
130130
131131 fn visit_foreign_item ( & mut self , i : & ' v hir:: ForeignItem ) {
132- self . record ( "ForeignItem" , Id :: Node ( i. id ) , i) ;
132+ self . record ( "ForeignItem" , Id :: Node ( i. hir_id ) , i) ;
133133 hir_visit:: walk_foreign_item ( self , i)
134134 }
135135
136136 fn visit_local ( & mut self , l : & ' v hir:: Local ) {
137- self . record ( "Local" , Id :: Node ( l. id ) , l) ;
137+ self . record ( "Local" , Id :: Node ( l. hir_id ) , l) ;
138138 hir_visit:: walk_local ( self , l)
139139 }
140140
141141 fn visit_block ( & mut self , b : & ' v hir:: Block ) {
142- self . record ( "Block" , Id :: Node ( b. id ) , b) ;
142+ self . record ( "Block" , Id :: Node ( b. hir_id ) , b) ;
143143 hir_visit:: walk_block ( self , b)
144144 }
145145
146146 fn visit_stmt ( & mut self , s : & ' v hir:: Stmt ) {
147- self . record ( "Stmt" , Id :: Node ( s. id ) , s) ;
147+ self . record ( "Stmt" , Id :: Node ( s. hir_id ) , s) ;
148148 hir_visit:: walk_stmt ( self , s)
149149 }
150150
@@ -154,17 +154,17 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
154154 }
155155
156156 fn visit_pat ( & mut self , p : & ' v hir:: Pat ) {
157- self . record ( "Pat" , Id :: Node ( p. id ) , p) ;
157+ self . record ( "Pat" , Id :: Node ( p. hir_id ) , p) ;
158158 hir_visit:: walk_pat ( self , p)
159159 }
160160
161161 fn visit_expr ( & mut self , ex : & ' v hir:: Expr ) {
162- self . record ( "Expr" , Id :: Node ( ex. id ) , ex) ;
162+ self . record ( "Expr" , Id :: Node ( ex. hir_id ) , ex) ;
163163 hir_visit:: walk_expr ( self , ex)
164164 }
165165
166166 fn visit_ty ( & mut self , t : & ' v hir:: Ty ) {
167- self . record ( "Ty" , Id :: Node ( t. id ) , t) ;
167+ self . record ( "Ty" , Id :: Node ( t. hir_id ) , t) ;
168168 hir_visit:: walk_ty ( self , t)
169169 }
170170
@@ -184,12 +184,12 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
184184 }
185185
186186 fn visit_trait_item ( & mut self , ti : & ' v hir:: TraitItem ) {
187- self . record ( "TraitItem" , Id :: Node ( ti. id ) , ti) ;
187+ self . record ( "TraitItem" , Id :: Node ( ti. hir_id ) , ti) ;
188188 hir_visit:: walk_trait_item ( self , ti)
189189 }
190190
191191 fn visit_impl_item ( & mut self , ii : & ' v hir:: ImplItem ) {
192- self . record ( "ImplItem" , Id :: Node ( ii. id ) , ii) ;
192+ self . record ( "ImplItem" , Id :: Node ( ii. hir_id ) , ii) ;
193193 hir_visit:: walk_impl_item ( self , ii)
194194 }
195195
@@ -199,7 +199,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
199199 }
200200
201201 fn visit_struct_field ( & mut self , s : & ' v hir:: StructField ) {
202- self . record ( "StructField" , Id :: Node ( s. id ) , s) ;
202+ self . record ( "StructField" , Id :: Node ( s. hir_id ) , s) ;
203203 hir_visit:: walk_struct_field ( self , s)
204204 }
205205
@@ -212,7 +212,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
212212 }
213213
214214 fn visit_lifetime ( & mut self , lifetime : & ' v hir:: Lifetime ) {
215- self . record ( "Lifetime" , Id :: Node ( lifetime. id ) , lifetime) ;
215+ self . record ( "Lifetime" , Id :: Node ( lifetime. hir_id ) , lifetime) ;
216216 hir_visit:: walk_lifetime ( self , lifetime)
217217 }
218218
@@ -234,7 +234,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
234234 }
235235
236236 fn visit_assoc_type_binding ( & mut self , type_binding : & ' v hir:: TypeBinding ) {
237- self . record ( "TypeBinding" , Id :: Node ( type_binding. id ) , type_binding) ;
237+ self . record ( "TypeBinding" , Id :: Node ( type_binding. hir_id ) , type_binding) ;
238238 hir_visit:: walk_assoc_type_binding ( self , type_binding)
239239 }
240240
@@ -243,7 +243,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
243243 }
244244
245245 fn visit_macro_def ( & mut self , macro_def : & ' v hir:: MacroDef ) {
246- self . record ( "MacroDef" , Id :: Node ( macro_def. id ) , macro_def) ;
246+ self . record ( "MacroDef" , Id :: Node ( macro_def. hir_id ) , macro_def) ;
247247 hir_visit:: walk_macro_def ( self , macro_def)
248248 }
249249}
0 commit comments