@@ -1012,7 +1012,7 @@ impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
10121012struct NamePrivacyVisitor < ' a , ' tcx > {
10131013 tcx : TyCtxt < ' tcx > ,
10141014 tables : & ' a ty:: TypeckTables < ' tcx > ,
1015- current_item : hir:: HirId ,
1015+ current_item : Option < hir:: HirId > ,
10161016 empty_tables : & ' a ty:: TypeckTables < ' tcx > ,
10171017}
10181018
@@ -1028,7 +1028,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
10281028 ) {
10291029 // definition of the field
10301030 let ident = Ident :: new ( kw:: Invalid , use_ctxt) ;
1031- let current_hir = self . current_item ;
1031+ let current_hir = self . current_item . unwrap ( ) ;
10321032 let def_id = self . tcx . adjust_ident_and_get_scope ( ident, def. did , current_hir) . 1 ;
10331033 if !def. is_enum ( ) && !field. vis . is_accessible_from ( def_id, self . tcx ) {
10341034 let label = if in_update_syntax {
@@ -1074,7 +1074,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
10741074 }
10751075
10761076 fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1077- let orig_current_item = mem:: replace ( & mut self . current_item , item. hir_id ) ;
1077+ let orig_current_item = mem:: replace ( & mut self . current_item , Some ( item. hir_id ) ) ;
10781078 let orig_tables =
10791079 mem:: replace ( & mut self . tables , item_tables ( self . tcx , item. hir_id , self . empty_tables ) ) ;
10801080 intravisit:: walk_item ( self , item) ;
@@ -2059,7 +2059,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: DefId) {
20592059 let mut visitor = NamePrivacyVisitor {
20602060 tcx,
20612061 tables : & empty_tables,
2062- current_item : hir :: DUMMY_HIR_ID ,
2062+ current_item : None ,
20632063 empty_tables : & empty_tables,
20642064 } ;
20652065 let ( module, span, hir_id) = tcx. hir ( ) . get_module ( module_def_id) ;
0 commit comments