@@ -212,29 +212,15 @@ impl<'a> ::ModuleS<'a> {
212212 } ) ;
213213 }
214214
215- let ( ref mut public_globs, ref mut private_globs) = * self . resolved_globs . borrow_mut ( ) ;
216-
217- // Check if the public globs are determined
218- if public_globs. len ( ) < self . public_glob_count . get ( ) {
219- return Indeterminate ;
220- }
221- for module in public_globs. iter ( ) {
222- if let Indeterminate = module. resolve_name ( name, ns, false ) {
223- return Indeterminate ;
224- }
225- }
226-
227- if !allow_private_imports {
228- return Failed ( None ) ;
229- }
230-
231- // Check if the private globs are determined
232- if private_globs. len ( ) < self . private_glob_count . get ( ) {
233- return Indeterminate ;
234- }
235- for module in private_globs. iter ( ) {
236- if let Indeterminate = module. resolve_name ( name, ns, false ) {
237- return Indeterminate ;
215+ // Check if the globs are determined
216+ for directive in self . globs . borrow ( ) . iter ( ) {
217+ if !allow_private_imports && !directive. is_public { continue }
218+ match directive. target_module . get ( ) {
219+ None => return Indeterminate ,
220+ Some ( target_module) => match target_module. resolve_name ( name, ns, false ) {
221+ Indeterminate => return Indeterminate ,
222+ _ => { }
223+ }
238224 }
239225 }
240226
@@ -259,6 +245,18 @@ impl<'a> ::ModuleS<'a> {
259245 } )
260246 }
261247
248+ pub fn add_import_directive ( & self , directive : ImportDirective < ' a > ) {
249+ let directive = self . arenas . alloc_import_directive ( directive) ;
250+ self . unresolved_imports . borrow_mut ( ) . push ( directive) ;
251+ if let GlobImport = directive. subclass {
252+ // We don't add prelude imports to the globs since they only affect lexical scopes,
253+ // which are not relevant to import resolution.
254+ if !directive. is_prelude {
255+ self . globs . borrow_mut ( ) . push ( directive) ;
256+ }
257+ }
258+ }
259+
262260 pub fn increment_outstanding_references_for ( & self , name : Name , ns : Namespace , is_public : bool ) {
263261 self . resolutions . borrow_mut ( ) . entry ( ( name, ns) ) . or_insert_with ( Default :: default)
264262 . increment_outstanding_references ( is_public) ;
@@ -603,12 +601,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
603601 return Success ( ( ) ) ;
604602 }
605603
606- // Add to target_module's glob_importers and module_'s resolved_globs
604+ // Add to target_module's glob_importers
607605 target_module. glob_importers . borrow_mut ( ) . push ( ( module_, directive) ) ;
608- match * module_. resolved_globs . borrow_mut ( ) {
609- ( ref mut public_globs, _) if directive. is_public => public_globs. push ( target_module) ,
610- ( _, ref mut private_globs) => private_globs. push ( target_module) ,
611- }
612606
613607 for ( & ( name, ns) , resolution) in target_module. resolutions . borrow ( ) . iter ( ) {
614608 if let Some ( Success ( binding) ) = resolution. try_result ( false ) {
@@ -635,8 +629,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
635629 // reporting conflicts, reporting the PRIVATE_IN_PUBLIC lint, and reporting unresolved imports.
636630 fn finalize_resolutions ( & mut self , module : Module < ' b > , report_unresolved_imports : bool ) {
637631 // Since import resolution is finished, globs will not define any more names.
638- module. public_glob_count . set ( 0 ) ; module. private_glob_count . set ( 0 ) ;
639- * module. resolved_globs . borrow_mut ( ) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
632+ * module. globs . borrow_mut ( ) = Vec :: new ( ) ;
640633
641634 let mut reexports = Vec :: new ( ) ;
642635 for ( & ( name, ns) , resolution) in module. resolutions . borrow ( ) . iter ( ) {
0 commit comments