@@ -211,7 +211,7 @@ impl<'a> ::ModuleS<'a> {
211
211
let ( ref mut public_globs, ref mut private_globs) = * self . resolved_globs . borrow_mut ( ) ;
212
212
213
213
// Check if the public globs are determined
214
- if self . pub_glob_count . get ( ) > 0 {
214
+ if public_globs . len ( ) < self . public_glob_count . get ( ) {
215
215
return Indeterminate ;
216
216
}
217
217
for module in public_globs. iter ( ) {
@@ -225,7 +225,7 @@ impl<'a> ::ModuleS<'a> {
225
225
}
226
226
227
227
// Check if the private globs are determined
228
- if self . glob_count . get ( ) > 0 {
228
+ if private_globs . len ( ) < self . private_glob_count . get ( ) {
229
229
return Indeterminate ;
230
230
}
231
231
for module in private_globs. iter ( ) {
@@ -322,23 +322,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
322
322
323
323
if self . resolver . unresolved_imports == 0 {
324
324
debug ! ( "(resolving imports) success" ) ;
325
- self . finalize_resolutions ( self . resolver . graph_root ) ;
325
+ self . finalize_resolutions ( self . resolver . graph_root , false ) ;
326
326
break ;
327
327
}
328
328
329
329
if self . resolver . unresolved_imports == prev_unresolved_imports {
330
330
// resolving failed
331
- self . finalize_resolutions ( self . resolver . graph_root ) ;
332
- if errors. len ( ) > 0 {
333
- for e in errors {
334
- self . import_resolving_error ( e)
335
- }
336
- } else {
337
- // Report unresolved imports only if no hard error was already reported
338
- // to avoid generating multiple errors on the same import.
339
- // Imports that are still indeterminate at this point are actually blocked
340
- // by errored imports, so there is no point reporting them.
341
- self . resolver . report_unresolved_imports ( self . resolver . graph_root ) ;
331
+ // Report unresolved imports only if no hard error was already reported
332
+ // to avoid generating multiple errors on the same import.
333
+ // Imports that are still indeterminate at this point are actually blocked
334
+ // by errored imports, so there is no point reporting them.
335
+ self . finalize_resolutions ( self . resolver . graph_root , errors. len ( ) == 0 ) ;
336
+ for e in errors {
337
+ self . import_resolving_error ( e)
342
338
}
343
339
break ;
344
340
}
@@ -444,16 +440,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
444
440
// Decrement the count of unresolved imports.
445
441
assert ! ( self . resolver. unresolved_imports >= 1 ) ;
446
442
self . resolver . unresolved_imports -= 1 ;
447
-
448
- if let GlobImport = import_directive. subclass {
449
- module_. dec_glob_count ( ) ;
450
- if import_directive. is_public {
451
- module_. dec_pub_glob_count ( ) ;
452
- }
453
- }
454
- if import_directive. is_public {
455
- module_. dec_pub_count ( ) ;
456
- }
457
443
Success ( ( ) )
458
444
} )
459
445
}
@@ -697,10 +683,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
697
683
}
698
684
699
685
// Miscellaneous post-processing, including recording reexports, recording shadowed traits,
700
- // reporting conflicts, and reporting the PRIVATE_IN_PUBLIC lint.
701
- fn finalize_resolutions ( & mut self , module : Module < ' b > ) {
686
+ // reporting conflicts, reporting the PRIVATE_IN_PUBLIC lint, and reporting unresolved imports .
687
+ fn finalize_resolutions ( & mut self , module : Module < ' b > , report_unresolved_imports : bool ) {
702
688
// Since import resolution is finished, globs will not define any more names.
703
- module. pub_glob_count . set ( 0 ) ; module. glob_count . set ( 0 ) ;
689
+ module. public_glob_count . set ( 0 ) ; module. private_glob_count . set ( 0 ) ;
704
690
* module. resolved_globs . borrow_mut ( ) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
705
691
706
692
let mut reexports = Vec :: new ( ) ;
@@ -743,8 +729,15 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
743
729
}
744
730
}
745
731
732
+ if report_unresolved_imports {
733
+ for import in module. unresolved_imports . borrow ( ) . iter ( ) {
734
+ resolve_error ( self . resolver , import. span , ResolutionError :: UnresolvedImport ( None ) ) ;
735
+ break ;
736
+ }
737
+ }
738
+
746
739
for ( _, child) in module. module_children . borrow ( ) . iter ( ) {
747
- self . finalize_resolutions ( child) ;
740
+ self . finalize_resolutions ( child, report_unresolved_imports ) ;
748
741
}
749
742
}
750
743
}
0 commit comments