@@ -48,14 +48,16 @@ pub(crate) struct ImportResolver<'r, 'ra, 'tcx> {
48
48
49
49
// outputs
50
50
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 ) > ,
52
53
import_bindings : PerNS < Vec < ( Module < ' ra > , Import < ' ra > , PendingBinding < ' ra > ) > > ,
53
54
}
54
55
55
56
struct ImportResolutionOutputs < ' ra > {
56
57
indeterminate_imports : Vec < Import < ' ra > > ,
57
58
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 ) > ,
59
61
import_bindings : PerNS < Vec < ( Module < ' ra > , Import < ' ra > , PendingBinding < ' ra > ) > > ,
60
62
}
61
63
@@ -65,17 +67,19 @@ impl<'r, 'ra, 'tcx> ImportResolver<'r, 'ra, 'tcx> {
65
67
r : cmr,
66
68
batch,
67
69
determined_imports : Vec :: new ( ) ,
68
- glob_imports : Vec :: new ( ) ,
69
70
import_bindings : PerNS :: default ( ) ,
71
+ glob_import_outputs : Vec :: new ( ) ,
72
+ glob_res_outputs : Vec :: new ( ) ,
70
73
}
71
74
}
72
75
73
76
fn into_outputs ( self ) -> ImportResolutionOutputs < ' ra > {
74
77
ImportResolutionOutputs {
75
78
indeterminate_imports : self . batch ,
76
79
determined_imports : self . determined_imports ,
77
- glob_imports : self . glob_imports ,
78
80
import_bindings : self . import_bindings ,
81
+ glob_import_outputs : self . glob_import_outputs ,
82
+ glob_res_outputs : self . glob_res_outputs ,
79
83
}
80
84
}
81
85
}
@@ -85,8 +89,12 @@ impl<'ra> ImportResolutionOutputs<'ra> {
85
89
r. indeterminate_imports = self . indeterminate_imports ;
86
90
r. determined_imports . extend ( self . determined_imports ) ;
87
91
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) ;
90
98
}
91
99
92
100
for ( ns, import_bindings) in self . import_bindings . into_iter_with ( ) {
@@ -964,14 +972,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
964
972
ImportKind :: Single { source, target, ref bindings, type_ns_only, .. } => {
965
973
( source, target, bindings, type_ns_only)
966
974
}
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) ;
975
977
return 0 ;
976
978
}
977
979
_ => unreachable ! ( ) ,
@@ -1565,7 +1567,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1565
1567
false
1566
1568
}
1567
1569
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 > ) {
1569
1571
// This function is only called for glob imports.
1570
1572
let ImportKind :: Glob { id, is_prelude, .. } = import. kind else { unreachable ! ( ) } ;
1571
1573
@@ -1587,7 +1589,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1587
1589
if module == import. parent_scope . module {
1588
1590
return ;
1589
1591
} else if is_prelude {
1590
- self . prelude = Some ( module) ;
1592
+ self . r . prelude . set ( Some ( module) ) ;
1591
1593
return ;
1592
1594
}
1593
1595
@@ -1616,18 +1618,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1616
1618
. resolution ( import. parent_scope . module , key)
1617
1619
. and_then ( |r| r. binding ( ) )
1618
1620
. is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
1619
- let _ = self . try_define_local (
1621
+ self . glob_import_outputs . push ( (
1620
1622
import. parent_scope . module ,
1621
- key. ident . 0 ,
1622
- key. ns ,
1623
+ key,
1623
1624
imported_binding,
1624
1625
warn_ambiguity,
1625
- ) ;
1626
+ ) ) ;
1626
1627
}
1627
1628
}
1628
1629
1629
1630
// 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 ( ) ) ) ) ;
1631
1632
}
1632
1633
1633
1634
// Miscellaneous post-processing, including recording re-exports,
0 commit comments