@@ -221,7 +221,7 @@ struct DefCollector<'a> {
221
221
deps : FxHashMap < Name , Dependency > ,
222
222
glob_imports : FxHashMap < LocalModuleId , Vec < ( LocalModuleId , Visibility , UseId ) > > ,
223
223
unresolved_imports : Vec < ImportDirective > ,
224
- indeterminate_imports : Vec < ImportDirective > ,
224
+ indeterminate_imports : Vec < ( ImportDirective , PerNs ) > ,
225
225
unresolved_macros : Vec < MacroDirective > ,
226
226
mod_dirs : FxHashMap < LocalModuleId , ModDir > ,
227
227
cfg_options : & ' a CfgOptions ,
@@ -415,16 +415,6 @@ impl DefCollector<'_> {
415
415
416
416
self . resolution_loop ( ) ;
417
417
418
- // Resolve all indeterminate resolved imports again
419
- // As some of the macros will expand newly import shadowing partial resolved imports
420
- // FIXME: We maybe could skip this, if we handle the indeterminate imports in `resolve_imports`
421
- // correctly
422
- let partial_resolved = self . indeterminate_imports . drain ( ..) . map ( |directive| {
423
- ImportDirective { status : PartialResolvedImport :: Unresolved , ..directive }
424
- } ) ;
425
- self . unresolved_imports . extend ( partial_resolved) ;
426
- self . resolve_imports ( ) ;
427
-
428
418
let unresolved_imports = mem:: take ( & mut self . unresolved_imports ) ;
429
419
// show unresolved imports in completion, etc
430
420
for directive in & unresolved_imports {
@@ -749,9 +739,9 @@ impl DefCollector<'_> {
749
739
. filter_map ( |mut directive| {
750
740
directive. status = self . resolve_import ( directive. module_id , & directive. import ) ;
751
741
match directive. status {
752
- PartialResolvedImport :: Indeterminate ( _ ) => {
742
+ PartialResolvedImport :: Indeterminate ( resolved ) => {
753
743
self . record_resolved_import ( & directive) ;
754
- self . indeterminate_imports . push ( directive) ;
744
+ self . indeterminate_imports . push ( ( directive, resolved ) ) ;
755
745
res = ReachedFixedPoint :: No ;
756
746
None
757
747
}
@@ -764,6 +754,33 @@ impl DefCollector<'_> {
764
754
}
765
755
} )
766
756
. collect ( ) ;
757
+
758
+ // Resolve all indeterminate resolved imports again
759
+ // As some of the macros will expand newly import shadowing partial resolved imports
760
+ // FIXME: We maybe could skip this, if we handle the indeterminate imports in `resolve_imports`
761
+ // correctly
762
+ let mut indeterminate_imports = std:: mem:: take ( & mut self . indeterminate_imports ) ;
763
+ indeterminate_imports. retain_mut ( |( directive, partially_resolved) | {
764
+ let partially_resolved = partially_resolved. availability ( ) ;
765
+ directive. status = self . resolve_import ( directive. module_id , & directive. import ) ;
766
+ match directive. status {
767
+ PartialResolvedImport :: Indeterminate ( import)
768
+ if partially_resolved != import. availability ( ) =>
769
+ {
770
+ self . record_resolved_import ( directive) ;
771
+ res = ReachedFixedPoint :: No ;
772
+ false
773
+ }
774
+ PartialResolvedImport :: Resolved ( _) => {
775
+ self . record_resolved_import ( directive) ;
776
+ res = ReachedFixedPoint :: No ;
777
+ false
778
+ }
779
+ _ => true ,
780
+ }
781
+ } ) ;
782
+ self . indeterminate_imports = indeterminate_imports;
783
+
767
784
res
768
785
}
769
786
0 commit comments