@@ -1012,7 +1012,7 @@ impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
1012
1012
struct NamePrivacyVisitor < ' a , ' tcx > {
1013
1013
tcx : TyCtxt < ' tcx > ,
1014
1014
tables : & ' a ty:: TypeckTables < ' tcx > ,
1015
- current_item : hir:: HirId ,
1015
+ current_item : Option < hir:: HirId > ,
1016
1016
empty_tables : & ' a ty:: TypeckTables < ' tcx > ,
1017
1017
}
1018
1018
@@ -1028,7 +1028,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
1028
1028
) {
1029
1029
// definition of the field
1030
1030
let ident = Ident :: new ( kw:: Invalid , use_ctxt) ;
1031
- let current_hir = self . current_item ;
1031
+ let current_hir = self . current_item . unwrap ( ) ;
1032
1032
let def_id = self . tcx . adjust_ident_and_get_scope ( ident, def. did , current_hir) . 1 ;
1033
1033
if !def. is_enum ( ) && !field. vis . is_accessible_from ( def_id, self . tcx ) {
1034
1034
let label = if in_update_syntax {
@@ -1074,7 +1074,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
1074
1074
}
1075
1075
1076
1076
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 ) ) ;
1078
1078
let orig_tables =
1079
1079
mem:: replace ( & mut self . tables , item_tables ( self . tcx , item. hir_id , self . empty_tables ) ) ;
1080
1080
intravisit:: walk_item ( self , item) ;
@@ -2059,7 +2059,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: DefId) {
2059
2059
let mut visitor = NamePrivacyVisitor {
2060
2060
tcx,
2061
2061
tables : & empty_tables,
2062
- current_item : hir :: DUMMY_HIR_ID ,
2062
+ current_item : None ,
2063
2063
empty_tables : & empty_tables,
2064
2064
} ;
2065
2065
let ( module, span, hir_id) = tcx. hir ( ) . get_module ( module_def_id) ;
0 commit comments