@@ -317,10 +317,17 @@ impl<'a> Resolver<'a> {
317
317
where T : ToNameBinding < ' a >
318
318
{
319
319
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| {
321
321
if let Some ( old_binding) = resolution. binding {
322
322
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
+ }
324
331
} else if old_binding. is_glob_import ( ) {
325
332
resolution. duplicate_globs . push ( old_binding) ;
326
333
resolution. binding = Some ( binding) ;
@@ -344,14 +351,17 @@ impl<'a> Resolver<'a> {
344
351
// during which the resolution might end up getting re-defined via a glob cycle.
345
352
let ( binding, t) = {
346
353
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 ( ) ;
348
355
349
356
let t = f ( self , resolution) ;
350
357
351
- if was_known { return t; }
352
358
match resolution. binding ( ) {
353
- Some ( binding ) => ( binding , t ) ,
359
+ _ if ! self . new_import_semantics && old_binding . is_some ( ) => return t ,
354
360
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
+ }
355
365
}
356
366
} ;
357
367
0 commit comments