@@ -17,7 +17,7 @@ use rustc_ast::{self as ast, Attribute, NestedMetaItem};
17
17
use rustc_data_structures:: fingerprint:: Fingerprint ;
18
18
use rustc_data_structures:: fx:: FxHashSet ;
19
19
use rustc_hir as hir;
20
- use rustc_hir:: def_id:: DefId ;
20
+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
21
21
use rustc_hir:: intravisit;
22
22
use rustc_hir:: itemlikevisit:: ItemLikeVisitor ;
23
23
use rustc_hir:: Node as HirNode ;
@@ -179,7 +179,7 @@ pub struct DirtyCleanVisitor<'tcx> {
179
179
180
180
impl DirtyCleanVisitor < ' tcx > {
181
181
/// Possibly "deserialize" the attribute into a clean/dirty assertion
182
- fn assertion_maybe ( & mut self , item_id : hir :: HirId , attr : & Attribute ) -> Option < Assertion > {
182
+ fn assertion_maybe ( & mut self , item_id : LocalDefId , attr : & Attribute ) -> Option < Assertion > {
183
183
let is_clean = if self . tcx . sess . check_name ( attr, sym:: rustc_dirty) {
184
184
false
185
185
} else if self . tcx . sess . check_name ( attr, sym:: rustc_clean) {
@@ -207,7 +207,7 @@ impl DirtyCleanVisitor<'tcx> {
207
207
/// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
208
208
fn assertion_auto (
209
209
& mut self ,
210
- item_id : hir :: HirId ,
210
+ item_id : LocalDefId ,
211
211
attr : & Attribute ,
212
212
is_clean : bool ,
213
213
) -> Assertion {
@@ -253,8 +253,9 @@ impl DirtyCleanVisitor<'tcx> {
253
253
254
254
/// Return all DepNode labels that should be asserted for this item.
255
255
/// index=0 is the "name" used for error messages
256
- fn auto_labels ( & mut self , item_id : hir:: HirId , attr : & Attribute ) -> ( & ' static str , Labels ) {
257
- let node = self . tcx . hir ( ) . get ( item_id) ;
256
+ fn auto_labels ( & mut self , item_id : LocalDefId , attr : & Attribute ) -> ( & ' static str , Labels ) {
257
+ let hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id ( item_id) ;
258
+ let node = self . tcx . hir ( ) . get ( hir_id) ;
258
259
let ( name, labels) = match node {
259
260
HirNode :: Item ( item) => {
260
261
match item. kind {
@@ -430,18 +431,17 @@ impl DirtyCleanVisitor<'tcx> {
430
431
}
431
432
}
432
433
433
- fn check_item ( & mut self , item_id : hir:: HirId , item_span : Span ) {
434
- let def_id = self . tcx . hir ( ) . local_def_id ( item_id) ;
435
- for attr in self . tcx . get_attrs ( def_id. to_def_id ( ) ) . iter ( ) {
434
+ fn check_item ( & mut self , item_id : LocalDefId , item_span : Span ) {
435
+ for attr in self . tcx . get_attrs ( item_id. to_def_id ( ) ) . iter ( ) {
436
436
let assertion = match self . assertion_maybe ( item_id, attr) {
437
437
Some ( a) => a,
438
438
None => continue ,
439
439
} ;
440
440
self . checked_attrs . insert ( attr. id ) ;
441
- for dep_node in self . dep_nodes ( & assertion. clean , def_id . to_def_id ( ) ) {
441
+ for dep_node in self . dep_nodes ( & assertion. clean , item_id . to_def_id ( ) ) {
442
442
self . assert_clean ( item_span, dep_node) ;
443
443
}
444
- for dep_node in self . dep_nodes ( & assertion. dirty , def_id . to_def_id ( ) ) {
444
+ for dep_node in self . dep_nodes ( & assertion. dirty , item_id . to_def_id ( ) ) {
445
445
self . assert_dirty ( item_span, dep_node) ;
446
446
}
447
447
}
@@ -450,19 +450,19 @@ impl DirtyCleanVisitor<'tcx> {
450
450
451
451
impl ItemLikeVisitor < ' tcx > for DirtyCleanVisitor < ' tcx > {
452
452
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
453
- self . check_item ( item. hir_id ( ) , item. span ) ;
453
+ self . check_item ( item. def_id , item. span ) ;
454
454
}
455
455
456
456
fn visit_trait_item ( & mut self , item : & hir:: TraitItem < ' _ > ) {
457
- self . check_item ( item. hir_id ( ) , item. span ) ;
457
+ self . check_item ( item. def_id , item. span ) ;
458
458
}
459
459
460
460
fn visit_impl_item ( & mut self , item : & hir:: ImplItem < ' _ > ) {
461
- self . check_item ( item. hir_id ( ) , item. span ) ;
461
+ self . check_item ( item. def_id , item. span ) ;
462
462
}
463
463
464
464
fn visit_foreign_item ( & mut self , item : & hir:: ForeignItem < ' _ > ) {
465
- self . check_item ( item. hir_id ( ) , item. span ) ;
465
+ self . check_item ( item. def_id , item. span ) ;
466
466
}
467
467
}
468
468
0 commit comments