@@ -454,6 +454,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
454454 module. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
455455 module. underscore_disambiguator . get ( )
456456 } ) ;
457+ // "Same res different import" ambiguity hack for macros introduced in #145108.
458+ // See related discussion for more info:
459+ // https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542057918.
460+ if ns == MacroNS
461+ && decl. is_glob_import ( )
462+ && decl. vis . get ( ) . is_public ( ) // is a glob that reexports a macro
463+ && self . macro_use_prelude . contains_key ( & ident. name ) // which also lives in macro_use world
464+ && let Some ( def_id) = res. opt_def_id ( )
465+ {
466+ self . macro_vis_hack_map . insert ( ( module, def_id) ) ;
467+ }
457468 self . update_local_resolution ( module, key, warn_ambiguity, |this, resolution| {
458469 if let Some ( old_decl) = resolution. best_decl ( ) {
459470 assert_ne ! ( decl, old_decl) ;
@@ -642,7 +653,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
642653 for ( import, side_effect) in import_resolutions {
643654 let SideEffect { imported_module, decls : side_effect_bindings } = side_effect;
644655 let parent = import. parent_scope . module ;
645-
646656 match ( & import. kind , side_effect_bindings) {
647657 (
648658 ImportKind :: Single { target, decls, .. } ,
@@ -1677,12 +1687,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16771687 module. for_each_child ( self , |this, ident, _, binding| {
16781688 let res = binding. res ( ) . expect_non_local ( ) ;
16791689 if res != def:: Res :: Err {
1680- let child = |reexport_chain| ModChild {
1681- ident : ident . 0 ,
1682- res ,
1683- vis : binding . vis ( ) ,
1684- reexport_chain ,
1690+ let vis = match res . opt_def_id ( ) {
1691+ Some ( def_id ) if self . macro_vis_hack_map . contains ( & ( module , def_id ) ) => {
1692+ Visibility :: Public
1693+ }
1694+ Some ( _ ) | None => binding . vis . get ( ) ,
16851695 } ;
1696+ let child = |reexport_chain| ModChild { ident : ident. 0 , res, vis, reexport_chain } ;
16861697 if let Some ( ( ambig_binding1, ambig_binding2) ) = binding. descent_to_ambiguity ( ) {
16871698 let main = child ( ambig_binding1. reexport_chain ( this) ) ;
16881699 let second = ModChild {
0 commit comments