@@ -117,13 +117,13 @@ struct Annotator<'a, 'tcx: 'a> {
117
117
impl < ' a , ' tcx : ' a > Annotator < ' a , ' tcx > {
118
118
// Determine the stability for a node based on its attributes and inherited
119
119
// 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 ] ,
121
121
item_sp : Span , kind : AnnotationKind , visit_children : F )
122
122
where F : FnOnce ( & mut Self )
123
123
{
124
124
if self . tcx . features ( ) . staged_api {
125
125
// This crate explicitly wants staged API.
126
- debug ! ( "annotate(id = {:?}, attrs = {:?})" , id , attrs) ;
126
+ debug ! ( "annotate(id = {:?}, attrs = {:?})" , hir_id , attrs) ;
127
127
if let Some ( ..) = attr:: find_deprecation ( & self . tcx . sess . parse_sess , attrs, item_sp) {
128
128
self . tcx . sess . span_err ( item_sp, "`#[deprecated]` cannot be used in staged api, \
129
129
use `#[rustc_deprecated]` instead") ;
@@ -178,7 +178,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
178
178
}
179
179
}
180
180
181
- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
182
181
self . index . stab_map . insert ( hir_id, stab) ;
183
182
184
183
let orig_parent_stab = replace ( & mut self . parent_stab , Some ( stab) ) ;
@@ -188,7 +187,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
188
187
debug ! ( "annotate: not found, parent = {:?}" , self . parent_stab) ;
189
188
if let Some ( stab) = self . parent_stab {
190
189
if stab. level . is_unstable ( ) {
191
- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
192
190
self . index . stab_map . insert ( hir_id, stab) ;
193
191
}
194
192
}
@@ -209,7 +207,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
209
207
// -Zforce-unstable-if-unmarked is set.
210
208
if let Some ( stab) = self . parent_stab {
211
209
if stab. level . is_unstable ( ) {
212
- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
213
210
self . index . stab_map . insert ( hir_id, stab) ;
214
211
}
215
212
}
@@ -220,7 +217,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
220
217
}
221
218
222
219
// `Deprecation` is just two pointers, no need to intern it
223
- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
224
220
let depr_entry = DeprecationEntry :: local ( depr, hir_id) ;
225
221
self . index . depr_map . insert ( hir_id, depr_entry. clone ( ) ) ;
226
222
@@ -229,7 +225,6 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
229
225
visit_children ( self ) ;
230
226
self . parent_depr = orig_parent_depr;
231
227
} else if let Some ( parent_depr) = self . parent_depr . clone ( ) {
232
- let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
233
228
self . index . depr_map . insert ( hir_id, parent_depr) ;
234
229
visit_children ( self ) ;
235
230
} else {
@@ -264,20 +259,20 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
264
259
}
265
260
hir:: ItemKind :: Struct ( ref sd, _) => {
266
261
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 , |_| { } )
268
263
}
269
264
}
270
265
_ => { }
271
266
}
272
267
273
- self . annotate ( i. id , & i. attrs , i. span , kind, |v| {
268
+ self . annotate ( i. hir_id , & i. attrs , i. span , kind, |v| {
274
269
intravisit:: walk_item ( v, i)
275
270
} ) ;
276
271
self . in_trait_impl = orig_in_trait_impl;
277
272
}
278
273
279
274
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| {
281
276
intravisit:: walk_trait_item ( v, ti) ;
282
277
} ) ;
283
278
}
@@ -288,31 +283,30 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
288
283
} else {
289
284
AnnotationKind :: Required
290
285
} ;
291
- self . annotate ( ii. id , & ii. attrs , ii. span , kind, |v| {
286
+ self . annotate ( ii. hir_id , & ii. attrs , ii. span , kind, |v| {
292
287
intravisit:: walk_impl_item ( v, ii) ;
293
288
} ) ;
294
289
}
295
290
296
291
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) } )
300
294
}
301
295
302
296
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| {
304
298
intravisit:: walk_struct_field ( v, s) ;
305
299
} ) ;
306
300
}
307
301
308
302
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| {
310
304
intravisit:: walk_foreign_item ( v, i) ;
311
305
} ) ;
312
306
}
313
307
314
308
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 , |_| { } ) ;
316
310
}
317
311
}
318
312
@@ -322,12 +316,12 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
322
316
}
323
317
324
318
impl < ' 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 ) {
327
320
let stab = self . tcx . stability ( ) . local_stability ( hir_id) ;
321
+ let node_id = self . tcx . hir ( ) . hir_to_node_id ( hir_id) ;
328
322
let is_error = !self . tcx . sess . opts . test &&
329
323
stab. is_none ( ) &&
330
- self . access_levels . is_reachable ( id ) ;
324
+ self . access_levels . is_reachable ( node_id ) ;
331
325
if is_error {
332
326
self . tcx . sess . span_err (
333
327
span,
@@ -350,42 +344,42 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
350
344
// optional. They inherit stability from their parents when unannotated.
351
345
hir:: ItemKind :: Impl ( .., None , _, _) | hir:: ItemKind :: ForeignMod ( ..) => { }
352
346
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 ( ) )
354
348
}
355
349
356
350
intravisit:: walk_item ( self , i)
357
351
}
358
352
359
353
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" ) ;
361
355
intravisit:: walk_trait_item ( self , ti) ;
362
356
}
363
357
364
358
fn visit_impl_item ( & mut self , ii : & ' tcx hir:: ImplItem ) {
365
359
let impl_def_id = self . tcx . hir ( ) . local_def_id ( self . tcx . hir ( ) . get_parent ( ii. id ) ) ;
366
360
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" ) ;
368
362
}
369
363
intravisit:: walk_impl_item ( self , ii) ;
370
364
}
371
365
372
366
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" ) ;
374
368
intravisit:: walk_variant ( self , var, g, item_id) ;
375
369
}
376
370
377
371
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" ) ;
379
373
intravisit:: walk_struct_field ( self , s) ;
380
374
}
381
375
382
376
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 ( ) ) ;
384
378
intravisit:: walk_foreign_item ( self , i) ;
385
379
}
386
380
387
381
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" ) ;
389
383
}
390
384
}
391
385
@@ -441,7 +435,7 @@ impl<'a, 'tcx> Index<'tcx> {
441
435
annotator. parent_stab = Some ( stability) ;
442
436
}
443
437
444
- annotator. annotate ( ast :: CRATE_NODE_ID ,
438
+ annotator. annotate ( hir :: CRATE_HIR_ID ,
445
439
& krate. attrs ,
446
440
krate. span ,
447
441
AnnotationKind :: Required ,
@@ -843,7 +837,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
843
837
tcx,
844
838
access_levels,
845
839
} ;
846
- missing. check_missing_stability ( ast :: CRATE_NODE_ID , krate. span , "crate" ) ;
840
+ missing. check_missing_stability ( hir :: CRATE_HIR_ID , krate. span , "crate" ) ;
847
841
intravisit:: walk_crate ( & mut missing, krate) ;
848
842
krate. visit_all_item_likes ( & mut missing. as_deep_visitor ( ) ) ;
849
843
}
0 commit comments