@@ -374,6 +374,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
374374 module. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
375375 module. underscore_disambiguator . get ( )
376376 } ) ;
377+ let tcx = self . tcx ( ) ;
378+ // "Same res different import" ambiguity hack for macros introduced in #145108.
379+ // See related discussion for more info:
380+ // https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542057918.
381+ if ns == MacroNS && binding. is_glob_import ( ) {
382+ if let Some ( def_id) = res. opt_def_id ( ) {
383+ self . greatest_vis_map
384+ . entry ( def_id)
385+ . and_modify ( |vis| {
386+ if !vis. is_at_least ( binding. vis , tcx) {
387+ * vis = binding. vis
388+ }
389+ } )
390+ . or_insert ( binding. vis ) ;
391+ }
392+ }
377393 self . update_local_resolution ( module, key, warn_ambiguity, |this, resolution| {
378394 if let Some ( old_binding) = resolution. best_binding ( ) {
379395 if res == Res :: Err && old_binding. res ( ) != Res :: Err {
@@ -623,12 +639,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
623639 for ( import, side_effect) in import_resolutions {
624640 let SideEffect { imported_module, bindings : side_effect_bindings } = side_effect;
625641 let parent = import. parent_scope . module ;
626-
627642 match ( & import. kind , side_effect_bindings) {
628643 (
629644 ImportKind :: Single { target, bindings, .. } ,
630645 SideEffectBindings :: Single { import_bindings } ,
631646 ) => {
647+ debug ! ( "{import_bindings:#?}" ) ;
632648 self . per_ns ( |this, ns| {
633649 match import_bindings[ ns] {
634650 Some ( Some ( binding) ) => {
@@ -687,6 +703,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
687703 . resolution ( import. parent_scope . module , key)
688704 . and_then ( |r| r. binding ( ) )
689705 . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
706+ debug ! ( "defining binding from glob: {imported_binding:#?}" ) ;
690707 let _ = self . try_define_local (
691708 parent,
692709 key. ident . 0 ,
@@ -1662,7 +1679,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16621679 next_binding = binding;
16631680 }
16641681
1665- children. push ( ModChild { ident : ident. 0 , res, vis : binding. vis , reexport_chain } ) ;
1682+ let vis = match res. opt_def_id ( ) {
1683+ Some ( def_id) => {
1684+ self . greatest_vis_map . get ( & def_id) . copied ( ) . unwrap_or ( binding. vis )
1685+ }
1686+ None => binding. vis ,
1687+ } ;
1688+ children. push ( ModChild { ident : ident. 0 , res, vis, reexport_chain } ) ;
16661689 }
16671690 } ) ;
16681691
0 commit comments