@@ -117,13 +117,13 @@ struct Annotator<'a, 'tcx: 'a> {
117117impl < ' a , ' tcx : ' a > Annotator < ' a , ' tcx > {
118118 // Determine the stability for a node based on its attributes and inherited
119119 // stability. The stability is recorded in the index and used as the parent.
120- fn annotate < F > ( & mut self , id : NodeId , attrs : & [ Attribute ] ,
120+ fn annotate < F > ( & mut self , hir_id : HirId , attrs : & [ Attribute ] ,
121121 item_sp : Span , kind : AnnotationKind , visit_children : F )
122122 where F : FnOnce ( & mut Self )
123123 {
124124 if self . tcx . features ( ) . staged_api {
125125 // This crate explicitly wants staged API.
126- debug ! ( "annotate(id = {:?}, attrs = {:?})" , id , attrs) ;
126+ debug ! ( "annotate(id = {:?}, attrs = {:?})" , hir_id , attrs) ;
127127 if let Some ( ..) = attr:: find_deprecation ( & self . tcx . sess . parse_sess , attrs, item_sp) {
128128 self . tcx . sess . span_err ( item_sp, "`#[deprecated]` cannot be used in staged api, \
129129 use `#[rustc_deprecated]` instead") ;
@@ -178,7 +178,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
178178 }
179179 }
180180
181- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
182181 self . index . stab_map . insert ( hir_id, stab) ;
183182
184183 let orig_parent_stab = replace ( & mut self . parent_stab , Some ( stab) ) ;
@@ -188,7 +187,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
188187 debug ! ( "annotate: not found, parent = {:?}" , self . parent_stab) ;
189188 if let Some ( stab) = self . parent_stab {
190189 if stab. level . is_unstable ( ) {
191- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
192190 self . index . stab_map . insert ( hir_id, stab) ;
193191 }
194192 }
@@ -209,7 +207,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
209207 // -Zforce-unstable-if-unmarked is set.
210208 if let Some ( stab) = self . parent_stab {
211209 if stab. level . is_unstable ( ) {
212- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
213210 self . index . stab_map . insert ( hir_id, stab) ;
214211 }
215212 }
@@ -220,7 +217,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
220217 }
221218
222219 // `Deprecation` is just two pointers, no need to intern it
223- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
224220 let depr_entry = DeprecationEntry :: local ( depr, hir_id) ;
225221 self . index . depr_map . insert ( hir_id, depr_entry. clone ( ) ) ;
226222
@@ -229,7 +225,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
229225 visit_children ( self ) ;
230226 self . parent_depr = orig_parent_depr;
231227 } else if let Some ( parent_depr) = self . parent_depr . clone ( ) {
232- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
233228 self . index . depr_map . insert ( hir_id, parent_depr) ;
234229 visit_children ( self ) ;
235230 } else {
@@ -264,20 +259,20 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
264259 }
265260 hir:: ItemKind :: Struct ( ref sd, _) => {
266261 if !sd. is_struct ( ) {
267- self . annotate ( sd. id ( ) , & i. attrs , i. span , AnnotationKind :: Required , |_| { } )
262+ self . annotate ( sd. hir_id ( ) , & i. attrs , i. span , AnnotationKind :: Required , |_| { } )
268263 }
269264 }
270265 _ => { }
271266 }
272267
273- self . annotate ( i. id , & i. attrs , i. span , kind, |v| {
268+ self . annotate ( i. hir_id , & i. attrs , i. span , kind, |v| {
274269 intravisit:: walk_item ( v, i)
275270 } ) ;
276271 self . in_trait_impl = orig_in_trait_impl;
277272 }
278273
279274 fn visit_trait_item ( & mut self , ti : & ' tcx hir:: TraitItem ) {
280- self . annotate ( ti. id , & ti. attrs , ti. span , AnnotationKind :: Required , |v| {
275+ self . annotate ( ti. hir_id , & ti. attrs , ti. span , AnnotationKind :: Required , |v| {
281276 intravisit:: walk_trait_item ( v, ti) ;
282277 } ) ;
283278 }
@@ -288,31 +283,30 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
288283 } else {
289284 AnnotationKind :: Required
290285 } ;
291- self . annotate ( ii. id , & ii. attrs , ii. span , kind, |v| {
286+ self . annotate ( ii. hir_id , & ii. attrs , ii. span , kind, |v| {
292287 intravisit:: walk_impl_item ( v, ii) ;
293288 } ) ;
294289 }
295290
296291 fn visit_variant ( & mut self , var : & ' tcx Variant , g : & ' tcx Generics , item_id : HirId ) {
297- self . annotate ( var. node . data . id ( ) , & var. node . attrs , var. span , AnnotationKind :: Required , |v| {
298- intravisit:: walk_variant ( v, var, g, item_id) ;
299- } )
292+ self . annotate ( var. node . data . hir_id ( ) , & var. node . attrs , var. span , AnnotationKind :: Required ,
293+ |v| { intravisit:: walk_variant ( v, var, g, item_id) } )
300294 }
301295
302296 fn visit_struct_field ( & mut self , s : & ' tcx StructField ) {
303- self . annotate ( s. id , & s. attrs , s. span , AnnotationKind :: Required , |v| {
297+ self . annotate ( s. hir_id , & s. attrs , s. span , AnnotationKind :: Required , |v| {
304298 intravisit:: walk_struct_field ( v, s) ;
305299 } ) ;
306300 }
307301
308302 fn visit_foreign_item ( & mut self , i : & ' tcx hir:: ForeignItem ) {
309- self . annotate ( i. id , & i. attrs , i. span , AnnotationKind :: Required , |v| {
303+ self . annotate ( i. hir_id , & i. attrs , i. span , AnnotationKind :: Required , |v| {
310304 intravisit:: walk_foreign_item ( v, i) ;
311305 } ) ;
312306 }
313307
314308 fn visit_macro_def ( & mut self , md : & ' tcx hir:: MacroDef ) {
315- self . annotate ( md. id , & md. attrs , md. span , AnnotationKind :: Required , |_| { } ) ;
309+ self . annotate ( md. hir_id , & md. attrs , md. span , AnnotationKind :: Required , |_| { } ) ;
316310 }
317311}
318312
@@ -322,12 +316,12 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
322316}
323317
324318impl < ' a , ' tcx : ' a > MissingStabilityAnnotations < ' a , ' tcx > {
325- fn check_missing_stability ( & self , id : NodeId , span : Span , name : & str ) {
326- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
319+ fn check_missing_stability ( & self , hir_id : HirId , span : Span , name : & str ) {
327320 let stab = self . tcx . stability ( ) . local_stability ( hir_id) ;
321+ let node_id = self . tcx . hir ( ) . hir_to_node_id ( hir_id) ;
328322 let is_error = !self . tcx . sess . opts . test &&
329323 stab. is_none ( ) &&
330- self . access_levels . is_reachable ( id ) ;
324+ self . access_levels . is_reachable ( node_id ) ;
331325 if is_error {
332326 self . tcx . sess . span_err (
333327 span,
@@ -350,42 +344,42 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
350344 // optional. They inherit stability from their parents when unannotated.
351345 hir:: ItemKind :: Impl ( .., None , _, _) | hir:: ItemKind :: ForeignMod ( ..) => { }
352346
353- _ => self . check_missing_stability ( i. id , i. span , i. node . descriptive_variant ( ) )
347+ _ => self . check_missing_stability ( i. hir_id , i. span , i. node . descriptive_variant ( ) )
354348 }
355349
356350 intravisit:: walk_item ( self , i)
357351 }
358352
359353 fn visit_trait_item ( & mut self , ti : & ' tcx hir:: TraitItem ) {
360- self . check_missing_stability ( ti. id , ti. span , "item" ) ;
354+ self . check_missing_stability ( ti. hir_id , ti. span , "item" ) ;
361355 intravisit:: walk_trait_item ( self , ti) ;
362356 }
363357
364358 fn visit_impl_item ( & mut self , ii : & ' tcx hir:: ImplItem ) {
365359 let impl_def_id = self . tcx . hir ( ) . local_def_id ( self . tcx . hir ( ) . get_parent ( ii. id ) ) ;
366360 if self . tcx . impl_trait_ref ( impl_def_id) . is_none ( ) {
367- self . check_missing_stability ( ii. id , ii. span , "item" ) ;
361+ self . check_missing_stability ( ii. hir_id , ii. span , "item" ) ;
368362 }
369363 intravisit:: walk_impl_item ( self , ii) ;
370364 }
371365
372366 fn visit_variant ( & mut self , var : & ' tcx Variant , g : & ' tcx Generics , item_id : HirId ) {
373- self . check_missing_stability ( var. node . data . id ( ) , var. span , "variant" ) ;
367+ self . check_missing_stability ( var. node . data . hir_id ( ) , var. span , "variant" ) ;
374368 intravisit:: walk_variant ( self , var, g, item_id) ;
375369 }
376370
377371 fn visit_struct_field ( & mut self , s : & ' tcx StructField ) {
378- self . check_missing_stability ( s. id , s. span , "field" ) ;
372+ self . check_missing_stability ( s. hir_id , s. span , "field" ) ;
379373 intravisit:: walk_struct_field ( self , s) ;
380374 }
381375
382376 fn visit_foreign_item ( & mut self , i : & ' tcx hir:: ForeignItem ) {
383- self . check_missing_stability ( i. id , i. span , i. node . descriptive_variant ( ) ) ;
377+ self . check_missing_stability ( i. hir_id , i. span , i. node . descriptive_variant ( ) ) ;
384378 intravisit:: walk_foreign_item ( self , i) ;
385379 }
386380
387381 fn visit_macro_def ( & mut self , md : & ' tcx hir:: MacroDef ) {
388- self . check_missing_stability ( md. id , md. span , "macro" ) ;
382+ self . check_missing_stability ( md. hir_id , md. span , "macro" ) ;
389383 }
390384}
391385
@@ -441,7 +435,7 @@ impl<'a, 'tcx> Index<'tcx> {
441435 annotator. parent_stab = Some ( stability) ;
442436 }
443437
444- annotator. annotate ( ast :: CRATE_NODE_ID ,
438+ annotator. annotate ( hir :: CRATE_HIR_ID ,
445439 & krate. attrs ,
446440 krate. span ,
447441 AnnotationKind :: Required ,
@@ -843,7 +837,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
843837 tcx,
844838 access_levels,
845839 } ;
846- missing. check_missing_stability ( ast :: CRATE_NODE_ID , krate. span , "crate" ) ;
840+ missing. check_missing_stability ( hir :: CRATE_HIR_ID , krate. span , "crate" ) ;
847841 intravisit:: walk_crate ( & mut missing, krate) ;
848842 krate. visit_all_item_likes ( & mut missing. as_deep_visitor ( ) ) ;
849843 }
0 commit comments