@@ -221,7 +221,7 @@ struct DefCollector<'a> {
221221 deps : FxHashMap < Name , Dependency > ,
222222 glob_imports : FxHashMap < LocalModuleId , Vec < ( LocalModuleId , Visibility , UseId ) > > ,
223223 unresolved_imports : Vec < ImportDirective > ,
224- indeterminate_imports : Vec < ImportDirective > ,
224+ indeterminate_imports : Vec < ( ImportDirective , PerNs ) > ,
225225 unresolved_macros : Vec < MacroDirective > ,
226226 mod_dirs : FxHashMap < LocalModuleId , ModDir > ,
227227 cfg_options : & ' a CfgOptions ,
@@ -415,16 +415,6 @@ impl DefCollector<'_> {
415415
416416 self . resolution_loop ( ) ;
417417
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-
428418 let unresolved_imports = mem:: take ( & mut self . unresolved_imports ) ;
429419 // show unresolved imports in completion, etc
430420 for directive in & unresolved_imports {
@@ -749,9 +739,9 @@ impl DefCollector<'_> {
749739 . filter_map ( |mut directive| {
750740 directive. status = self . resolve_import ( directive. module_id , & directive. import ) ;
751741 match directive. status {
752- PartialResolvedImport :: Indeterminate ( _ ) => {
742+ PartialResolvedImport :: Indeterminate ( resolved ) => {
753743 self . record_resolved_import ( & directive) ;
754- self . indeterminate_imports . push ( directive) ;
744+ self . indeterminate_imports . push ( ( directive, resolved ) ) ;
755745 res = ReachedFixedPoint :: No ;
756746 None
757747 }
@@ -764,6 +754,33 @@ impl DefCollector<'_> {
764754 }
765755 } )
766756 . 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+
767784 res
768785 }
769786
0 commit comments