@@ -48,14 +48,16 @@ pub(crate) struct ImportResolver<'r, 'ra, 'tcx> {
4848
4949 // outputs
5050 determined_imports : Vec < Import < ' ra > > ,
51- glob_imports : Vec < Import < ' ra > > ,
51+ glob_import_outputs : Vec < ( Module < ' ra > , BindingKey , NameBinding < ' ra > , bool ) > ,
52+ glob_res_outputs : Vec < ( NodeId , PartialRes ) > ,
5253 import_bindings : PerNS < Vec < ( Module < ' ra > , Import < ' ra > , PendingBinding < ' ra > ) > > ,
5354}
5455
5556struct ImportResolutionOutputs < ' ra > {
5657 indeterminate_imports : Vec < Import < ' ra > > ,
5758 determined_imports : Vec < Import < ' ra > > ,
58- glob_imports : Vec < Import < ' ra > > ,
59+ glob_import_outputs : Vec < ( Module < ' ra > , BindingKey , NameBinding < ' ra > , bool ) > ,
60+ glob_res_outputs : Vec < ( NodeId , PartialRes ) > ,
5961 import_bindings : PerNS < Vec < ( Module < ' ra > , Import < ' ra > , PendingBinding < ' ra > ) > > ,
6062}
6163
@@ -65,17 +67,19 @@ impl<'r, 'ra, 'tcx> ImportResolver<'r, 'ra, 'tcx> {
6567 r : cmr,
6668 batch,
6769 determined_imports : Vec :: new ( ) ,
68- glob_imports : Vec :: new ( ) ,
6970 import_bindings : PerNS :: default ( ) ,
71+ glob_import_outputs : Vec :: new ( ) ,
72+ glob_res_outputs : Vec :: new ( ) ,
7073 }
7174 }
7275
7376 fn into_outputs ( self ) -> ImportResolutionOutputs < ' ra > {
7477 ImportResolutionOutputs {
7578 indeterminate_imports : self . batch ,
7679 determined_imports : self . determined_imports ,
77- glob_imports : self . glob_imports ,
7880 import_bindings : self . import_bindings ,
81+ glob_import_outputs : self . glob_import_outputs ,
82+ glob_res_outputs : self . glob_res_outputs ,
7983 }
8084 }
8185}
@@ -85,8 +89,12 @@ impl<'ra> ImportResolutionOutputs<'ra> {
8589 r. indeterminate_imports = self . indeterminate_imports ;
8690 r. determined_imports . extend ( self . determined_imports ) ;
8791
88- for glob in self . glob_imports {
89- r. resolve_glob_import ( glob) ;
92+ for ( module, key, binding, warn_ambiguity) in self . glob_import_outputs {
93+ let _ = r. try_define_local ( module, key. ident . 0 , key. ns , binding, warn_ambiguity) ;
94+ }
95+
96+ for ( id, res) in self . glob_res_outputs {
97+ r. record_partial_res ( id, res) ;
9098 }
9199
92100 for ( ns, import_bindings) in self . import_bindings . into_iter_with ( ) {
@@ -964,14 +972,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
964972 ImportKind :: Single { source, target, ref bindings, type_ns_only, .. } => {
965973 ( source, target, bindings, type_ns_only)
966974 }
967- ImportKind :: Glob { is_prelude, .. } => {
968- if is_prelude
969- && let ModuleOrUniformRoot :: Module ( module) =
970- import. imported_module . get ( ) . unwrap ( )
971- {
972- self . r . _get_mut_unchecked ( ) . prelude = Some ( module) ;
973- }
974- self . glob_imports . push ( import) ;
975+ ImportKind :: Glob { .. } => {
976+ self . resolve_glob_import ( import) ;
975977 return 0 ;
976978 }
977979 _ => unreachable ! ( ) ,
@@ -1565,7 +1567,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15651567 false
15661568 }
15671569
1568- fn resolve_glob_import ( & mut self , import : Import < ' ra > ) {
1570+ fn resolve_glob_import < ' r > ( self : & mut ImportResolver < ' r , ' ra , ' tcx > , import : Import < ' ra > ) {
15691571 // This function is only called for glob imports.
15701572 let ImportKind :: Glob { id, is_prelude, .. } = import. kind else { unreachable ! ( ) } ;
15711573
@@ -1587,7 +1589,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15871589 if module == import. parent_scope . module {
15881590 return ;
15891591 } else if is_prelude {
1590- self . prelude = Some ( module) ;
1592+ self . r . prelude . set ( Some ( module) ) ;
15911593 return ;
15921594 }
15931595
@@ -1616,18 +1618,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16161618 . resolution ( import. parent_scope . module , key)
16171619 . and_then ( |r| r. binding ( ) )
16181620 . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
1619- let _ = self . try_define_local (
1621+ self . glob_import_outputs . push ( (
16201622 import. parent_scope . module ,
1621- key. ident . 0 ,
1622- key. ns ,
1623+ key,
16231624 imported_binding,
16241625 warn_ambiguity,
1625- ) ;
1626+ ) ) ;
16261627 }
16271628 }
16281629
16291630 // Record the destination of this import
1630- self . record_partial_res ( id, PartialRes :: new ( module. res ( ) . unwrap ( ) ) ) ;
1631+ self . glob_res_outputs . push ( ( id, PartialRes :: new ( module. res ( ) . unwrap ( ) ) ) ) ;
16311632 }
16321633
16331634 // Miscellaneous post-processing, including recording re-exports,
0 commit comments