@@ -260,14 +260,15 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
260
260
return ;
261
261
}
262
262
263
- let imports = module. imports . borrow ( ) ;
263
+ let mut imports = module. imports . borrow_mut ( ) ;
264
264
let import_count = imports. len ( ) ;
265
- while module. resolved_import_count . get ( ) < import_count {
265
+ let mut indeterminate_imports = Vec :: new ( ) ;
266
+ while module. resolved_import_count . get ( ) + indeterminate_imports. len ( ) < import_count {
266
267
let import_index = module. resolved_import_count . get ( ) ;
267
- let import_directive = & ( * imports) [ import_index] ;
268
268
match self . resolve_import_for_module ( module. clone ( ) ,
269
- import_directive ) {
269
+ & imports [ import_index ] ) {
270
270
ResolveResult :: Failed ( err) => {
271
+ let import_directive = & imports[ import_index] ;
271
272
let ( span, help) = match err {
272
273
Some ( ( span, msg) ) => ( span, format ! ( ". {}" , msg) ) ,
273
274
None => ( import_directive. span , String :: new ( ) )
@@ -279,13 +280,17 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
279
280
help) ;
280
281
self . resolver . resolve_error ( span, & msg[ ..] ) ;
281
282
}
282
- ResolveResult :: Indeterminate => break , // Bail out. We'll come around next time.
283
+ ResolveResult :: Indeterminate => {
284
+ indeterminate_imports. push ( imports. swap_remove ( import_index) ) ;
285
+ continue ;
286
+ } ,
283
287
ResolveResult :: Success ( ( ) ) => ( ) // Good. Continue.
284
288
}
285
-
286
289
module. resolved_import_count
287
290
. set ( module. resolved_import_count . get ( ) + 1 ) ;
288
291
}
292
+ // put back all the unresolved imports, for next pass
293
+ imports. extend ( indeterminate_imports) ;
289
294
}
290
295
291
296
/// Attempts to resolve the given import. The return value indicates
@@ -654,10 +659,12 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
654
659
target) ;
655
660
656
661
if value_result. is_unbound ( ) && type_result. is_unbound ( ) {
657
- let msg = format ! ( "There is no `{}` in `{}`" ,
658
- token:: get_name( source) ,
659
- module_to_string( & target_module) ) ;
660
- return ResolveResult :: Failed ( Some ( ( directive. span , msg) ) ) ;
662
+ // Due to chained imports, it is possible that this import is simply not yet
663
+ // resolved, so we settle with Indeterminate.
664
+ // The main loop of the algorithm will break anyway is a pass does not resolve
665
+ // anything more.
666
+ debug ! ( "(resolving single import) unresolved for now, bailing out" ) ;
667
+ return ResolveResult :: Indeterminate ;
661
668
}
662
669
let value_used_public = value_used_reexport || value_used_public;
663
670
let type_used_public = type_used_reexport || type_used_public;
0 commit comments