@@ -17,7 +17,7 @@ use rustc_ast::{self as ast, Attribute, NestedMetaItem};
1717use rustc_data_structures:: fingerprint:: Fingerprint ;
1818use rustc_data_structures:: fx:: FxHashSet ;
1919use rustc_hir as hir;
20- use rustc_hir:: def_id:: DefId ;
20+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2121use rustc_hir:: intravisit;
2222use rustc_hir:: itemlikevisit:: ItemLikeVisitor ;
2323use rustc_hir:: Node as HirNode ;
@@ -179,7 +179,7 @@ pub struct DirtyCleanVisitor<'tcx> {
179179
180180impl DirtyCleanVisitor < ' tcx > {
181181 /// 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 > {
183183 let is_clean = if self . tcx . sess . check_name ( attr, sym:: rustc_dirty) {
184184 false
185185 } else if self . tcx . sess . check_name ( attr, sym:: rustc_clean) {
@@ -207,7 +207,7 @@ impl DirtyCleanVisitor<'tcx> {
207207 /// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
208208 fn assertion_auto (
209209 & mut self ,
210- item_id : hir :: HirId ,
210+ item_id : LocalDefId ,
211211 attr : & Attribute ,
212212 is_clean : bool ,
213213 ) -> Assertion {
@@ -253,8 +253,9 @@ impl DirtyCleanVisitor<'tcx> {
253253
254254 /// Return all DepNode labels that should be asserted for this item.
255255 /// 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) ;
258259 let ( name, labels) = match node {
259260 HirNode :: Item ( item) => {
260261 match item. kind {
@@ -430,18 +431,17 @@ impl DirtyCleanVisitor<'tcx> {
430431 }
431432 }
432433
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 ( ) {
436436 let assertion = match self . assertion_maybe ( item_id, attr) {
437437 Some ( a) => a,
438438 None => continue ,
439439 } ;
440440 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 ( ) ) {
442442 self . assert_clean ( item_span, dep_node) ;
443443 }
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 ( ) ) {
445445 self . assert_dirty ( item_span, dep_node) ;
446446 }
447447 }
@@ -450,19 +450,19 @@ impl DirtyCleanVisitor<'tcx> {
450450
451451impl ItemLikeVisitor < ' tcx > for DirtyCleanVisitor < ' tcx > {
452452 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 ) ;
454454 }
455455
456456 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 ) ;
458458 }
459459
460460 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 ) ;
462462 }
463463
464464 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 ) ;
466466 }
467467}
468468
0 commit comments