@@ -547,13 +547,6 @@ impl ModuleKind {
547547 ModuleKind :: Def ( .., name) => name,
548548 }
549549 }
550-
551- fn opt_def_id ( & self ) -> Option < DefId > {
552- match self {
553- ModuleKind :: Def ( _, def_id, _) => Some ( * def_id) ,
554- _ => None ,
555- }
556- }
557550}
558551
559552/// Combination of a symbol and its macros 2.0 normalized hygiene context.
@@ -791,7 +784,10 @@ impl<'ra> Module<'ra> {
791784 }
792785
793786 fn opt_def_id ( self ) -> Option < DefId > {
794- self . kind . opt_def_id ( )
787+ match self . kind {
788+ ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
789+ _ => None ,
790+ }
795791 }
796792
797793 // `self` resolves to the first module ancestor that `is_normal`.
@@ -1454,19 +1450,14 @@ impl<'ra> ResolverArenas<'ra> {
14541450 & ' ra self ,
14551451 parent : Option < Module < ' ra > > ,
14561452 kind : ModuleKind ,
1457- vis : Visibility < DefId > ,
14581453 expn_id : ExpnId ,
14591454 span : Span ,
14601455 no_implicit_prelude : bool ,
14611456 ) -> Module < ' ra > {
14621457 let self_decl = match kind {
1463- ModuleKind :: Def ( def_kind, def_id, _) => Some ( self . new_def_decl (
1464- Res :: Def ( def_kind, def_id) ,
1465- vis,
1466- span,
1467- LocalExpnId :: ROOT ,
1468- None ,
1469- ) ) ,
1458+ ModuleKind :: Def ( def_kind, def_id, _) => {
1459+ Some ( self . new_pub_def_decl ( Res :: Def ( def_kind, def_id) , span, LocalExpnId :: ROOT ) )
1460+ }
14701461 ModuleKind :: Block => None ,
14711462 } ;
14721463 Module ( Interned :: new_unchecked ( self . modules . alloc ( ModuleData :: new (
@@ -1648,7 +1639,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16481639 let graph_root = arenas. new_module (
16491640 None ,
16501641 ModuleKind :: Def ( DefKind :: Mod , root_def_id, None ) ,
1651- Visibility :: Public ,
16521642 ExpnId :: root ( ) ,
16531643 crate_span,
16541644 attr:: contains_name ( attrs, sym:: no_implicit_prelude) ,
@@ -1658,7 +1648,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16581648 let empty_module = arenas. new_module (
16591649 None ,
16601650 ModuleKind :: Def ( DefKind :: Mod , root_def_id, None ) ,
1661- Visibility :: Public ,
16621651 ExpnId :: root ( ) ,
16631652 DUMMY_SP ,
16641653 true ,
@@ -1760,9 +1749,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17601749 span : Span ,
17611750 no_implicit_prelude : bool ,
17621751 ) -> Module < ' ra > {
1763- let vis =
1764- kind. opt_def_id ( ) . map_or ( Visibility :: Public , |def_id| self . tcx . visibility ( def_id) ) ;
1765- let module = self . arenas . new_module ( parent, kind, vis, expn_id, span, no_implicit_prelude) ;
1752+ let module = self . arenas . new_module ( parent, kind, expn_id, span, no_implicit_prelude) ;
17661753 self . local_modules . push ( module) ;
17671754 if let Some ( def_id) = module. opt_def_id ( ) {
17681755 self . local_module_map . insert ( def_id. expect_local ( ) , module) ;
@@ -1778,9 +1765,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17781765 span : Span ,
17791766 no_implicit_prelude : bool ,
17801767 ) -> Module < ' ra > {
1781- let vis =
1782- kind. opt_def_id ( ) . map_or ( Visibility :: Public , |def_id| self . tcx . visibility ( def_id) ) ;
1783- let module = self . arenas . new_module ( parent, kind, vis, expn_id, span, no_implicit_prelude) ;
1768+ let module = self . arenas . new_module ( parent, kind, expn_id, span, no_implicit_prelude) ;
17841769 self . extern_module_map . borrow_mut ( ) . insert ( module. def_id ( ) , module) ;
17851770 module
17861771 }
0 commit comments