@@ -664,8 +664,6 @@ struct CommonModuleData<'ra> {
664664 /// Mapping between names and their (possibly in-progress) resolutions in this module.
665665 /// Resolutions in modules from other crates are not populated until accessed.
666666 lazy_resolutions : Resolutions < ' ra > ,
667- /// True if this is a module from other crate that needs to be populated on access.
668- populate_on_access : CacheCell < bool > ,
669667 /// Whether `#[no_implicit_prelude]` is active.
670668 no_implicit_prelude : bool ,
671669 /// Used to memoize the traits in this module for faster searches through all traits in scope.
@@ -692,6 +690,8 @@ struct LocalModuleData<'ra> {
692690
693691struct ExternModuleData < ' ra > {
694692 common : CommonModuleData < ' ra > ,
693+ /// True if this is a module from other crate that needs to be populated on access.
694+ populate_on_access : CacheCell < bool > ,
695695}
696696
697697/// All modules are unique and allocated on a same arena,
@@ -723,7 +723,6 @@ impl<'ra> CommonModuleData<'ra> {
723723 no_implicit_prelude : bool ,
724724 arenas : & ' ra ResolverArenas < ' ra > ,
725725 ) -> Self {
726- let is_foreign = !kind. is_local ( ) ;
727726 let self_decl = match kind {
728727 ModuleKind :: Def ( def_kind, def_id, _, _) => {
729728 let expn_id = expansion. as_local ( ) . unwrap_or ( LocalExpnId :: ROOT ) ;
@@ -735,7 +734,6 @@ impl<'ra> CommonModuleData<'ra> {
735734 parent,
736735 kind,
737736 lazy_resolutions : Default :: default ( ) ,
738- populate_on_access : CacheCell :: new ( is_foreign) ,
739737 no_implicit_prelude,
740738 traits : CmRefCell :: new ( None ) ,
741739 span,
@@ -932,9 +930,8 @@ impl<'ra> ExternModule<'ra> {
932930 assert ! ( !kind. is_local( ) ) ;
933931 let common =
934932 CommonModuleData :: new ( parent, kind, vis, expn_id, span, no_implicit_prelude, arenas) ;
935- ExternModule ( Interned :: new_unchecked (
936- arenas. extern_modules . alloc ( ExternModuleData { common } ) ,
937- ) )
933+ let data = ExternModuleData { common, populate_on_access : CacheCell :: new ( true ) } ;
934+ ExternModule ( Interned :: new_unchecked ( arenas. extern_modules . alloc ( data) ) )
938935 }
939936
940937 fn to_module ( self ) -> Module < ' ra > {
@@ -2208,13 +2205,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22082205 }
22092206
22102207 fn resolutions ( & self , module : Module < ' ra > ) -> & ' ra Resolutions < ' ra > {
2211- if module. populate_on_access . get ( ) {
2212- module. populate_on_access . set ( false ) ;
2213- self . build_reduced_graph_external ( module. expect_extern ( ) ) ;
2214- }
22152208 match module {
22162209 Module :: Local ( m) => & m. 0 . 0 . lazy_resolutions ,
2217- Module :: Extern ( m) => & m. 0 . 0 . lazy_resolutions ,
2210+ Module :: Extern ( m) => {
2211+ if m. populate_on_access . get ( ) {
2212+ m. populate_on_access . set ( false ) ;
2213+ self . build_reduced_graph_external ( m) ;
2214+ }
2215+ & m. 0 . 0 . lazy_resolutions
2216+ }
22182217 }
22192218 }
22202219
0 commit comments