@@ -317,10 +317,17 @@ impl<'a> Resolver<'a> {
317317        where  T :  ToNameBinding < ' a > 
318318    { 
319319        let  binding = self . arenas . alloc_name_binding ( binding. to_name_binding ( ) ) ; 
320-         self . update_resolution ( module,  name,  ns,  |_ ,  resolution| { 
320+         self . update_resolution ( module,  name,  ns,  |this ,  resolution| { 
321321            if  let  Some ( old_binding)  = resolution. binding  { 
322322                if  binding. is_glob_import ( )  { 
323-                     resolution. duplicate_globs . push ( binding) ; 
323+                     if  !this. new_import_semantics  || !old_binding. is_glob_import ( )  { 
324+                         resolution. duplicate_globs . push ( binding) ; 
325+                     }  else  if  binding. def ( )  != old_binding. def ( )  { 
326+                         resolution. duplicate_globs . push ( binding) ; 
327+                     }  else  if  !old_binding. vis . is_at_least ( binding. vis ,  this)  { 
328+                         // We are glob-importing the same item but with greater visibility. 
329+                         resolution. binding  = Some ( binding) ; 
330+                     } 
324331                }  else  if  old_binding. is_glob_import ( )  { 
325332                    resolution. duplicate_globs . push ( old_binding) ; 
326333                    resolution. binding  = Some ( binding) ; 
@@ -344,14 +351,17 @@ impl<'a> Resolver<'a> {
344351        // during which the resolution might end up getting re-defined via a glob cycle. 
345352        let  ( binding,  t)  = { 
346353            let  mut  resolution = & mut  * self . resolution ( module,  name,  ns) . borrow_mut ( ) ; 
347-             let  was_known  = resolution. binding ( ) . is_some ( ) ; 
354+             let  old_binding  = resolution. binding ( ) ; 
348355
349356            let  t = f ( self ,  resolution) ; 
350357
351-             if  was_known {  return  t;  } 
352358            match  resolution. binding ( )  { 
353-                 Some ( binding )  => ( binding ,  t ) , 
359+                 _  if  ! self . new_import_semantics  && old_binding . is_some ( )  => return  t , 
354360                None  => return  t, 
361+                 Some ( binding)  => match  old_binding { 
362+                     Some ( old_binding)  if  old_binding as  * const  _  == binding as  * const  _  => return  t, 
363+                     _ => ( binding,  t) , 
364+                 } 
355365            } 
356366        } ; 
357367
0 commit comments