@@ -53,7 +53,7 @@ enum SideEffectBindings<'ra> {
53
53
import_bindings : PerNS < Option < Option < NameBinding < ' ra > > > > ,
54
54
} ,
55
55
Glob {
56
- import_bindings : Vec < ( NameBinding < ' ra > , BindingKey , bool /* warn_ambiguity */ ) > ,
56
+ import_bindings : Vec < ( NameBinding < ' ra > , BindingKey ) > ,
57
57
} ,
58
58
}
59
59
@@ -601,9 +601,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
601
601
& mut self ,
602
602
import_resolutions : Vec < ( Import < ' ra > , SideEffect < ' ra > ) > ,
603
603
) {
604
- self . determined_imports . reserve ( self . determined_imports . len ( ) ) ;
605
604
for ( import, side_effect) in import_resolutions. iter ( ) {
606
- self . determined_imports . push ( * import) ;
607
605
let SideEffect { imported_module, .. } = side_effect;
608
606
import. imported_module . set ( Some ( * imported_module) ) ;
609
607
@@ -679,12 +677,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
679
677
. emit ( ) ;
680
678
}
681
679
682
- for ( binding, key, warn_ambiguity) in import_bindings {
680
+ for ( binding, key) in import_bindings {
681
+ let imported_binding = self . import ( binding, import) ;
682
+ let warn_ambiguity = self
683
+ . resolution ( import. parent_scope . module , key)
684
+ . and_then ( |r| r. binding ( ) )
685
+ . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
683
686
let _ = self . try_define_local (
684
687
parent,
685
688
key. ident . 0 ,
686
689
key. ns ,
687
- binding ,
690
+ imported_binding ,
688
691
warn_ambiguity,
689
692
) ;
690
693
}
@@ -1592,47 +1595,40 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1592
1595
false
1593
1596
}
1594
1597
1595
- fn resolve_glob_import < ' r > (
1596
- self : & mut CmResolver < ' r , ' ra , ' tcx > ,
1598
+ fn resolve_glob_import (
1599
+ & self ,
1597
1600
import : Import < ' ra > ,
1598
1601
imported_module : ModuleOrUniformRoot < ' ra > ,
1599
1602
) -> SideEffectBindings < ' ra > {
1600
- // This function is only called for glob imports.
1601
- let ImportKind :: Glob { .. } = import. kind else { unreachable ! ( ) } ;
1603
+ match imported_module {
1604
+ ModuleOrUniformRoot :: Module ( module) if module != import. parent_scope . module => {
1605
+ let import_bindings = self
1606
+ . resolutions ( module)
1607
+ . borrow ( )
1608
+ . iter ( )
1609
+ . filter_map ( |( key, resolution) | {
1610
+ let binding = resolution. borrow ( ) . binding ( ) ?;
1611
+ let mut key = * key;
1612
+ let scope = match key
1613
+ . ident
1614
+ . 0
1615
+ . span
1616
+ . reverse_glob_adjust ( module. expansion , import. span )
1617
+ {
1618
+ Some ( Some ( def) ) => self . expn_def_scope ( def) ,
1619
+ Some ( None ) => import. parent_scope . module ,
1620
+ None => return None ,
1621
+ } ;
1622
+ self . is_accessible_from ( binding. vis , scope) . then ( || ( binding, key) )
1623
+ } )
1624
+ . collect :: < Vec < _ > > ( ) ;
1602
1625
1603
- let ModuleOrUniformRoot :: Module ( module) = imported_module else {
1604
- return SideEffectBindings :: None ;
1605
- } ;
1626
+ SideEffectBindings :: Glob { import_bindings }
1627
+ }
1606
1628
1607
- if module == import . parent_scope . module {
1608
- return SideEffectBindings :: None ;
1629
+ // Errors are reported in `commit_imports_resolutions`
1630
+ _ => SideEffectBindings :: None ,
1609
1631
}
1610
-
1611
- let import_bindings = self
1612
- . resolutions ( module)
1613
- . borrow ( )
1614
- . iter ( )
1615
- . filter_map ( |( key, resolution) | {
1616
- let binding = resolution. borrow ( ) . binding ( ) ?;
1617
- let mut key = * key;
1618
- let scope =
1619
- match key. ident . 0 . span . reverse_glob_adjust ( module. expansion , import. span ) {
1620
- Some ( Some ( def) ) => self . expn_def_scope ( def) ,
1621
- Some ( None ) => import. parent_scope . module ,
1622
- None => return None ,
1623
- } ;
1624
- self . is_accessible_from ( binding. vis , scope) . then ( || {
1625
- let imported_binding = self . import ( binding, import) ;
1626
- let warn_ambiguity = self
1627
- . resolution ( import. parent_scope . module , key)
1628
- . and_then ( |r| r. binding ( ) )
1629
- . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
1630
- ( imported_binding, key, warn_ambiguity)
1631
- } )
1632
- } )
1633
- . collect :: < Vec < _ > > ( ) ;
1634
-
1635
- SideEffectBindings :: Glob { import_bindings }
1636
1632
}
1637
1633
1638
1634
// Miscellaneous post-processing, including recording re-exports,
0 commit comments