@@ -409,11 +409,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
409
409
GlobImport => {
410
410
assert ! ( module_. glob_count. get( ) >= 1 ) ;
411
411
module_. glob_count . set ( module_. glob_count . get ( ) - 1 ) ;
412
+ if import_directive. is_public {
413
+ assert ! ( module_. pub_glob_count. get( ) >= 1 ) ;
414
+ module_. pub_glob_count . set ( module_. pub_glob_count . get ( ) - 1 ) ;
415
+ }
412
416
}
413
417
SingleImport ( ..) => {
414
418
// Ignore.
415
419
}
416
420
}
421
+ if import_directive. is_public {
422
+ assert ! ( module_. pub_count. get( ) >= 1 ) ;
423
+ module_. pub_count . set ( module_. pub_count . get ( ) - 1 ) ;
424
+ }
417
425
}
418
426
419
427
return resolution_result;
@@ -503,8 +511,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
503
511
// containing module, bail out. We don't know enough to be
504
512
// able to resolve this import.
505
513
506
- if target_module. glob_count . get ( ) > 0 {
507
- debug ! ( "(resolving single import) unresolved glob; \
514
+ if target_module. pub_glob_count . get ( ) > 0 {
515
+ debug ! ( "(resolving single import) unresolved pub glob; \
508
516
bailing out") ;
509
517
return ResolveResult :: Indeterminate ;
510
518
}
@@ -767,16 +775,22 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
767
775
768
776
// We must bail out if the node has unresolved imports of any kind
769
777
// (including globs).
770
- if ! ( * target_module) . all_imports_resolved ( ) {
778
+ if ( * target_module) . pub_count . get ( ) > 0 {
771
779
debug ! ( "(resolving glob import) target module has unresolved \
772
- imports; bailing out") ;
780
+ pub imports; bailing out") ;
773
781
return ResolveResult :: Indeterminate ;
774
782
}
775
783
776
- assert_eq ! ( target_module. glob_count. get( ) , 0 ) ;
777
-
778
784
// Add all resolved imports from the containing module.
779
785
let import_resolutions = target_module. import_resolutions . borrow ( ) ;
786
+
787
+ if module_. import_resolutions . borrow_state ( ) != :: std:: cell:: BorrowState :: Unused {
788
+ // In this case, target_module == module_
789
+ // This means we are trying to glob import a module into itself,
790
+ // and it is a no-go
791
+ return ResolveResult :: Indeterminate ;
792
+ }
793
+
780
794
for ( ident, target_import_resolution) in import_resolutions. iter ( ) {
781
795
debug ! ( "(resolving glob import) writing module resolution \
782
796
{} into `{}`",
0 commit comments