@@ -231,7 +231,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
231231 // (i.e. variants, fields, and trait items) inherits from the visibility
232232 // of the enum or trait.
233233 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 ( )
235235 }
236236 // Otherwise, the visibility is restricted to the nearest parent `mod` item.
237237 _ => ty:: Visibility :: Restricted (
@@ -437,7 +437,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
437437 let mut source = module_path. pop ( ) . unwrap ( ) ;
438438 let mut type_ns_only = false ;
439439
440- self . r . visibilities . insert ( self . r . local_def_id ( id) , vis) ;
440+ self . r . feed_visibility ( self . r . local_def_id ( id) , vis) ;
441441
442442 if nested {
443443 // Correctly handle `self`
@@ -552,7 +552,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
552552 max_vis : Cell :: new ( None ) ,
553553 id,
554554 } ;
555- self . r . visibilities . insert ( self . r . local_def_id ( id) , vis) ;
555+ self . r . feed_visibility ( self . r . local_def_id ( id) , vis) ;
556556 self . add_import ( prefix, kind, use_tree. span , item, root_span, item. id , vis) ;
557557 }
558558 ast:: UseTreeKind :: Nested ( ref items) => {
@@ -629,7 +629,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
629629 let local_def_id = self . r . local_def_id ( item. id ) ;
630630 let def_id = local_def_id. to_def_id ( ) ;
631631
632- self . r . visibilities . insert ( local_def_id, vis) ;
632+ self . r . feed_visibility ( local_def_id, vis) ;
633633
634634 match item. kind {
635635 ItemKind :: Use ( ref use_tree) => {
@@ -753,7 +753,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
753753 let ctor_res =
754754 Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id. to_def_id ( ) ) ;
755755 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) ;
757757 // We need the field visibility spans also for the constructor for E0603.
758758 self . insert_field_visibilities_local ( ctor_def_id. to_def_id ( ) , vdata) ;
759759
@@ -899,7 +899,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
899899 let vis = self . resolve_visibility ( & item. vis ) ;
900900 let res = Res :: Def ( def_kind, def_id) ;
901901 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) ;
903903 }
904904
905905 fn build_reduced_graph_for_block ( & mut self , block : & Block ) {
@@ -1233,7 +1233,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
12331233 self . r . check_reserved_macro_name ( ident, res) ;
12341234 self . insert_unused_macro ( ident, def_id, item. id ) ;
12351235 }
1236- self . r . visibilities . insert ( def_id, vis) ;
1236+ self . r . feed_visibility ( def_id, vis) ;
12371237 let scope = self . r . arenas . alloc_macro_rules_scope ( MacroRulesScope :: Binding (
12381238 self . r . arenas . alloc_macro_rules_binding ( MacroRulesBinding {
12391239 parent_macro_rules_scope : parent_scope. macro_rules ,
@@ -1257,7 +1257,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
12571257 self . insert_unused_macro ( ident, def_id, item. id ) ;
12581258 }
12591259 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) ;
12611261 self . parent_scope . macro_rules
12621262 }
12631263 }
@@ -1359,7 +1359,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
13591359 // Trait impl item visibility is inherited from its trait when not specified
13601360 // explicitly. In that case we cannot determine it here in early resolve,
13611361 // 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) ;
13631363 }
13641364
13651365 if ctxt == AssocCtxt :: Trait {
@@ -1438,7 +1438,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
14381438 self . visit_invoc ( sf. id ) ;
14391439 } else {
14401440 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) ;
14421442 visit:: walk_field_def ( self , sf) ;
14431443 }
14441444 }
@@ -1460,7 +1460,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
14601460 let res = Res :: Def ( DefKind :: Variant , def_id. to_def_id ( ) ) ;
14611461 let vis = self . resolve_visibility ( & variant. vis ) ;
14621462 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) ;
14641464
14651465 // If the variant is marked as non_exhaustive then lower the visibility to within the crate.
14661466 let ctor_vis =
@@ -1476,7 +1476,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
14761476 let ctor_res =
14771477 Res :: Def ( DefKind :: Ctor ( CtorOf :: Variant , ctor_kind) , ctor_def_id. to_def_id ( ) ) ;
14781478 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) ;
14801480 }
14811481
14821482 // Record field names for error reporting.
0 commit comments