@@ -374,21 +374,16 @@ 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 ( ) ;
378377 // "Same res different import" ambiguity hack for macros introduced in #145108.
379378 // See related discussion for more info:
380379 // 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- }
380+ if ns == MacroNS
381+ && binding. is_glob_import ( )
382+ && binding. vis . is_public ( ) // is a glob that reexports a macro
383+ && self . macro_use_prelude . contains_key ( & ident. name ) // which also lives in macro_use world
384+ && let Some ( def_id) = res. opt_def_id ( )
385+ {
386+ self . macro_vis_hack_map . insert ( def_id) ;
392387 }
393388 self . update_local_resolution ( module, key, warn_ambiguity, |this, resolution| {
394389 if let Some ( old_binding) = resolution. best_binding ( ) {
@@ -1678,14 +1673,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16781673 }
16791674
16801675 let vis = match res. opt_def_id ( ) {
1681- Some ( def_id) => {
1682- let vis =
1683- self . greatest_vis_map . get ( & def_id) . copied ( ) . unwrap_or ( binding. vis ) ;
1684- // macros exported through `macro_export` are not placed in this map, so
1685- // hack the hack and make sure we still keep the best visibility.
1686- if !vis. is_at_least ( binding. vis , self . tcx ( ) ) { binding. vis } else { vis }
1687- }
1688- None => binding. vis ,
1676+ Some ( def_id) if self . macro_vis_hack_map . contains ( & def_id) => Visibility :: Public ,
1677+ Some ( _) | None => binding. vis ,
16891678 } ;
16901679 children. push ( ModChild { ident : ident. 0 , res, vis, reexport_chain } ) ;
16911680 }
0 commit comments