@@ -231,7 +231,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
231
231
// (i.e. variants, fields, and trait items) inherits from the visibility
232
232
// of the enum or trait.
233
233
ModuleKind :: Def ( DefKind :: Enum | DefKind :: Trait , def_id, _) => {
234
- self . r . visibilities [ & def_id. expect_local ( ) ]
234
+ self . r . tcx . visibility ( def_id) . expect_local ( )
235
235
}
236
236
// Otherwise, the visibility is restricted to the nearest parent `mod` item.
237
237
_ => ty:: Visibility :: Restricted (
@@ -437,7 +437,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
437
437
let mut source = module_path. pop ( ) . unwrap ( ) ;
438
438
let mut type_ns_only = false ;
439
439
440
- self . r . visibilities . insert ( self . r . local_def_id ( id) , vis) ;
440
+ self . r . feed_visibility ( self . r . local_def_id ( id) , vis) ;
441
441
442
442
if nested {
443
443
// Correctly handle `self`
@@ -552,7 +552,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
552
552
max_vis : Cell :: new ( None ) ,
553
553
id,
554
554
} ;
555
- self . r . visibilities . insert ( self . r . local_def_id ( id) , vis) ;
555
+ self . r . feed_visibility ( self . r . local_def_id ( id) , vis) ;
556
556
self . add_import ( prefix, kind, use_tree. span , item, root_span, item. id , vis) ;
557
557
}
558
558
ast:: UseTreeKind :: Nested ( ref items) => {
@@ -629,7 +629,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
629
629
let local_def_id = self . r . local_def_id ( item. id ) ;
630
630
let def_id = local_def_id. to_def_id ( ) ;
631
631
632
- self . r . visibilities . insert ( local_def_id, vis) ;
632
+ self . r . feed_visibility ( local_def_id, vis) ;
633
633
634
634
match item. kind {
635
635
ItemKind :: Use ( ref use_tree) => {
@@ -753,7 +753,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
753
753
let ctor_res =
754
754
Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id. to_def_id ( ) ) ;
755
755
self . r . define ( parent, ident, ValueNS , ( ctor_res, ctor_vis, sp, expansion) ) ;
756
- self . r . visibilities . insert ( ctor_def_id, ctor_vis) ;
756
+ self . r . feed_visibility ( ctor_def_id, ctor_vis) ;
757
757
// We need the field visibility spans also for the constructor for E0603.
758
758
self . insert_field_visibilities_local ( ctor_def_id. to_def_id ( ) , vdata) ;
759
759
@@ -899,7 +899,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
899
899
let vis = self . resolve_visibility ( & item. vis ) ;
900
900
let res = Res :: Def ( def_kind, def_id) ;
901
901
self . r . define ( parent, item. ident , ns, ( res, vis, item. span , expansion) ) ;
902
- self . r . visibilities . insert ( local_def_id, vis) ;
902
+ self . r . feed_visibility ( local_def_id, vis) ;
903
903
}
904
904
905
905
fn build_reduced_graph_for_block ( & mut self , block : & Block ) {
@@ -1233,7 +1233,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1233
1233
self . r . check_reserved_macro_name ( ident, res) ;
1234
1234
self . insert_unused_macro ( ident, def_id, item. id ) ;
1235
1235
}
1236
- self . r . visibilities . insert ( def_id, vis) ;
1236
+ self . r . feed_visibility ( def_id, vis) ;
1237
1237
let scope = self . r . arenas . alloc_macro_rules_scope ( MacroRulesScope :: Binding (
1238
1238
self . r . arenas . alloc_macro_rules_binding ( MacroRulesBinding {
1239
1239
parent_macro_rules_scope : parent_scope. macro_rules ,
@@ -1257,7 +1257,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1257
1257
self . insert_unused_macro ( ident, def_id, item. id ) ;
1258
1258
}
1259
1259
self . r . define ( module, ident, MacroNS , ( res, vis, span, expansion) ) ;
1260
- self . r . visibilities . insert ( def_id, vis) ;
1260
+ self . r . feed_visibility ( def_id, vis) ;
1261
1261
self . parent_scope . macro_rules
1262
1262
}
1263
1263
}
@@ -1359,7 +1359,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1359
1359
// Trait impl item visibility is inherited from its trait when not specified
1360
1360
// explicitly. In that case we cannot determine it here in early resolve,
1361
1361
// so we leave a hole in the visibility table to be filled later.
1362
- self . r . visibilities . insert ( local_def_id, vis) ;
1362
+ self . r . feed_visibility ( local_def_id, vis) ;
1363
1363
}
1364
1364
1365
1365
if ctxt == AssocCtxt :: Trait {
@@ -1438,7 +1438,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1438
1438
self . visit_invoc ( sf. id ) ;
1439
1439
} else {
1440
1440
let vis = self . resolve_visibility ( & sf. vis ) ;
1441
- self . r . visibilities . insert ( self . r . local_def_id ( sf. id ) , vis) ;
1441
+ self . r . feed_visibility ( self . r . local_def_id ( sf. id ) , vis) ;
1442
1442
visit:: walk_field_def ( self , sf) ;
1443
1443
}
1444
1444
}
@@ -1460,7 +1460,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1460
1460
let res = Res :: Def ( DefKind :: Variant , def_id. to_def_id ( ) ) ;
1461
1461
let vis = self . resolve_visibility ( & variant. vis ) ;
1462
1462
self . r . define ( parent, ident, TypeNS , ( res, vis, variant. span , expn_id) ) ;
1463
- self . r . visibilities . insert ( def_id, vis) ;
1463
+ self . r . feed_visibility ( def_id, vis) ;
1464
1464
1465
1465
// If the variant is marked as non_exhaustive then lower the visibility to within the crate.
1466
1466
let ctor_vis =
@@ -1476,7 +1476,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1476
1476
let ctor_res =
1477
1477
Res :: Def ( DefKind :: Ctor ( CtorOf :: Variant , ctor_kind) , ctor_def_id. to_def_id ( ) ) ;
1478
1478
self . r . define ( parent, ident, ValueNS , ( ctor_res, ctor_vis, variant. span , expn_id) ) ;
1479
- self . r . visibilities . insert ( ctor_def_id, ctor_vis) ;
1479
+ self . r . feed_visibility ( ctor_def_id, ctor_vis) ;
1480
1480
}
1481
1481
1482
1482
// Record field names for error reporting.
0 commit comments