@@ -9,11 +9,9 @@ use crate::def_collector::collect_definitions;
99use crate :: imports:: { Import , ImportKind } ;
1010use crate :: macros:: { MacroRulesBinding , MacroRulesScope , MacroRulesScopeRef } ;
1111use crate :: Namespace :: { self , MacroNS , TypeNS , ValueNS } ;
12- use crate :: { CrateLint , Determinacy , PathResult , ResolutionError , VisResolutionError } ;
13- use crate :: {
14- ExternPreludeEntry , ModuleOrUniformRoot , ParentScope , PerNS , Resolver , ResolverArenas ,
15- } ;
16- use crate :: { Module , ModuleData , ModuleKind , NameBinding , NameBindingKind , Segment , ToNameBinding } ;
12+ use crate :: { CrateLint , Determinacy , ExternPreludeEntry , Module , ModuleKind , ModuleOrUniformRoot } ;
13+ use crate :: { NameBinding , NameBindingKind , ParentScope , PathResult , PerNS , ResolutionError } ;
14+ use crate :: { Resolver , ResolverArenas , Segment , ToNameBinding , VisResolutionError } ;
1715
1816use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
1917use rustc_ast:: { self as ast, AssocItem , AssocItemKind , MetaItemKind , StmtKind } ;
@@ -142,13 +140,14 @@ impl<'a> Resolver<'a> {
142140 } ;
143141
144142 // Allocate and return a new module with the information we found
145- let kind = ModuleKind :: Def ( DefKind :: Mod , def_id, name) ;
146- let module = self . arenas . alloc_module ( ModuleData :: new (
143+ let module = self . arenas . new_module (
147144 parent,
148- kind ,
145+ ModuleKind :: Def ( DefKind :: Mod , def_id , name ) ,
149146 self . cstore ( ) . module_expansion_untracked ( def_id, & self . session ) ,
150147 self . cstore ( ) . get_span_untracked ( def_id, & self . session ) ,
151- ) ) ;
148+ // FIXME: Account for `#[no_implicit_prelude]` attributes.
149+ parent. map_or ( false , |module| module. no_implicit_prelude ) ,
150+ ) ;
152151 self . extern_module_map . insert ( def_id, module) ;
153152 module
154153 }
@@ -767,13 +766,14 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
767766 }
768767
769768 ItemKind :: Mod ( ..) => {
770- let module_kind = ModuleKind :: Def ( DefKind :: Mod , def_id, ident. name ) ;
771- let module = self . r . arenas . alloc_module ( ModuleData {
772- no_implicit_prelude : parent. no_implicit_prelude || {
773- self . r . session . contains_name ( & item. attrs , sym:: no_implicit_prelude)
774- } ,
775- ..ModuleData :: new ( Some ( parent) , module_kind, expansion. to_expn_id ( ) , item. span )
776- } ) ;
769+ let module = self . r . arenas . new_module (
770+ Some ( parent) ,
771+ ModuleKind :: Def ( DefKind :: Mod , def_id, ident. name ) ,
772+ expansion. to_expn_id ( ) ,
773+ item. span ,
774+ parent. no_implicit_prelude
775+ || self . r . session . contains_name ( & item. attrs , sym:: no_implicit_prelude) ,
776+ ) ;
777777 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
778778 self . r . module_map . insert ( local_def_id, module) ;
779779
@@ -806,9 +806,13 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
806806 }
807807
808808 ItemKind :: Enum ( _, _) => {
809- let module_kind = ModuleKind :: Def ( DefKind :: Enum , def_id, ident. name ) ;
810- let module =
811- self . r . new_module ( parent, module_kind, expansion. to_expn_id ( ) , item. span ) ;
809+ let module = self . r . arenas . new_module (
810+ Some ( parent) ,
811+ ModuleKind :: Def ( DefKind :: Enum , def_id, ident. name ) ,
812+ expansion. to_expn_id ( ) ,
813+ item. span ,
814+ parent. no_implicit_prelude ,
815+ ) ;
812816 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
813817 self . parent_scope . module = module;
814818 }
@@ -876,9 +880,13 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
876880
877881 ItemKind :: Trait ( ..) => {
878882 // Add all the items within to a new module.
879- let module_kind = ModuleKind :: Def ( DefKind :: Trait , def_id, ident. name ) ;
880- let module =
881- self . r . new_module ( parent, module_kind, expansion. to_expn_id ( ) , item. span ) ;
883+ let module = self . r . arenas . new_module (
884+ Some ( parent) ,
885+ ModuleKind :: Def ( DefKind :: Trait , def_id, ident. name ) ,
886+ expansion. to_expn_id ( ) ,
887+ item. span ,
888+ parent. no_implicit_prelude ,
889+ ) ;
882890 self . r . define ( parent, ident, TypeNS , ( module, vis, sp, expansion) ) ;
883891 self . parent_scope . module = module;
884892 }
@@ -915,11 +923,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
915923 let parent = self . parent_scope . module ;
916924 let expansion = self . parent_scope . expansion ;
917925 if self . block_needs_anonymous_module ( block) {
918- let module = self . r . new_module (
919- parent,
926+ let module = self . r . arenas . new_module (
927+ Some ( parent) ,
920928 ModuleKind :: Block ( block. id ) ,
921929 expansion. to_expn_id ( ) ,
922930 block. span ,
931+ parent. no_implicit_prelude ,
923932 ) ;
924933 self . r . block_map . insert ( block. id , module) ;
925934 self . parent_scope . module = module; // Descend into the block.
@@ -935,11 +944,13 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
935944 // Record primary definitions.
936945 match res {
937946 Res :: Def ( kind @ ( DefKind :: Mod | DefKind :: Enum | DefKind :: Trait ) , def_id) => {
938- let module = self . r . new_module (
939- parent,
947+ let module = self . r . arenas . new_module (
948+ Some ( parent) ,
940949 ModuleKind :: Def ( kind, def_id, ident. name ) ,
941950 expansion. to_expn_id ( ) ,
942951 span,
952+ // FIXME: Account for `#[no_implicit_prelude]` attributes.
953+ parent. no_implicit_prelude ,
943954 ) ;
944955 self . r . define ( parent, ident, TypeNS , ( module, vis, span, expansion) ) ;
945956 }
0 commit comments