@@ -10,7 +10,7 @@ use rustc_data_structures::fx::FxHashSet;
10
10
use rustc_errors:: struct_span_err;
11
11
use rustc_hir as hir;
12
12
use rustc_hir:: def:: { DefKind , Res } ;
13
- use rustc_hir:: def_id:: { CrateNum , DefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
13
+ use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
14
14
use rustc_hir:: intravisit:: { self , DeepVisitor , NestedVisitorMap , Visitor } ;
15
15
use rustc_hir:: { AssocItemKind , HirIdSet , Node , PatKind } ;
16
16
use rustc_middle:: bug;
@@ -1174,15 +1174,17 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
1174
1174
struct TypePrivacyVisitor < ' a , ' tcx > {
1175
1175
tcx : TyCtxt < ' tcx > ,
1176
1176
tables : & ' a ty:: TypeckTables < ' tcx > ,
1177
- current_item : DefId ,
1177
+ current_item : LocalDefId ,
1178
1178
in_body : bool ,
1179
1179
span : Span ,
1180
1180
empty_tables : & ' a ty:: TypeckTables < ' tcx > ,
1181
1181
}
1182
1182
1183
1183
impl < ' a , ' tcx > TypePrivacyVisitor < ' a , ' tcx > {
1184
1184
fn item_is_accessible ( & self , did : DefId ) -> bool {
1185
- def_id_visibility ( self . tcx , did) . 0 . is_accessible_from ( self . current_item , self . tcx )
1185
+ def_id_visibility ( self . tcx , did)
1186
+ . 0
1187
+ . is_accessible_from ( self . current_item . to_def_id ( ) , self . tcx )
1186
1188
}
1187
1189
1188
1190
// Take node-id of an expression or pattern and check its type for privacy.
@@ -1387,10 +1389,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
1387
1389
1388
1390
// Check types in item interfaces.
1389
1391
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1390
- let orig_current_item = mem:: replace (
1391
- & mut self . current_item ,
1392
- self . tcx . hir ( ) . local_def_id ( item. hir_id ) . to_def_id ( ) ,
1393
- ) ;
1392
+ let orig_current_item =
1393
+ mem:: replace ( & mut self . current_item , self . tcx . hir ( ) . local_def_id ( item. hir_id ) ) ;
1394
1394
let orig_in_body = mem:: replace ( & mut self . in_body , false ) ;
1395
1395
let orig_tables =
1396
1396
mem:: replace ( & mut self . tables , item_tables ( self . tcx , item. hir_id , self . empty_tables ) ) ;
@@ -2076,7 +2076,7 @@ pub fn provide(providers: &mut Providers<'_>) {
2076
2076
} ;
2077
2077
}
2078
2078
2079
- fn check_mod_privacy ( tcx : TyCtxt < ' _ > , module_def_id : DefId ) {
2079
+ fn check_mod_privacy ( tcx : TyCtxt < ' _ > , module_def_id : LocalDefId ) {
2080
2080
let empty_tables = ty:: TypeckTables :: empty ( None ) ;
2081
2081
2082
2082
// Check privacy of names not checked in previous compilation stages.
@@ -2086,7 +2086,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: DefId) {
2086
2086
current_item : None ,
2087
2087
empty_tables : & empty_tables,
2088
2088
} ;
2089
- let ( module, span, hir_id) = tcx. hir ( ) . get_module ( module_def_id. expect_local ( ) ) ;
2089
+ let ( module, span, hir_id) = tcx. hir ( ) . get_module ( module_def_id) ;
2090
2090
2091
2091
intravisit:: walk_mod ( & mut visitor, module, hir_id) ;
2092
2092
0 commit comments