@@ -343,66 +343,67 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
343
343
self . check_reserved_macro_name ( key. ident , res) ;
344
344
self . set_binding_parent_module ( binding, module) ;
345
345
self . update_resolution ( module, key, warn_ambiguity, |this, resolution| {
346
- if let Some ( old_binding) = resolution. non_glob_binding {
346
+ if let Some ( old_binding) = resolution. late_binding ( ) {
347
347
if res == Res :: Err && old_binding. res ( ) != Res :: Err {
348
348
// Do not override real bindings with `Res::Err`s from error recovery.
349
349
return Ok ( ( ) ) ;
350
350
}
351
351
match ( old_binding. is_glob_import ( ) , binding. is_glob_import ( ) ) {
352
352
( true , true ) => {
353
+ let ( glob_binding, old_glob_binding) = ( binding, old_binding) ;
353
354
// FIXME: remove `!binding.is_ambiguity_recursive()` after delete the warning ambiguity.
354
355
if !binding. is_ambiguity_recursive ( )
355
356
&& let NameBindingKind :: Import { import : old_import, .. } =
356
- old_binding . kind
357
- && let NameBindingKind :: Import { import, .. } = binding . kind
357
+ old_glob_binding . kind
358
+ && let NameBindingKind :: Import { import, .. } = glob_binding . kind
358
359
&& old_import == import
359
360
{
360
- // We should replace the `old_binding` with `binding` regardless
361
- // of whether they has same resolution or not when they are
362
- // imported from the same glob-import statement .
363
- resolution. non_glob_binding = Some ( binding ) ;
364
- } else if res != old_binding . res ( ) {
365
- resolution. non_glob_binding = Some ( this. new_ambiguity_binding (
361
+ // When imported from the same glob-import statement, we should replace
362
+ // `old_glob_binding` with `glob_binding`, regardless of whether
363
+ // they have the same resolution or not .
364
+ resolution. glob_binding = Some ( glob_binding ) ;
365
+ } else if res != old_glob_binding . res ( ) {
366
+ resolution. glob_binding = Some ( this. new_ambiguity_binding (
366
367
AmbiguityKind :: GlobVsGlob ,
367
- old_binding ,
368
- binding ,
368
+ old_glob_binding ,
369
+ glob_binding ,
369
370
warn_ambiguity,
370
371
) ) ;
371
372
} else if !old_binding. vis . is_at_least ( binding. vis , this. tcx ) {
372
373
// We are glob-importing the same item but with greater visibility.
373
- resolution. non_glob_binding = Some ( binding ) ;
374
+ resolution. glob_binding = Some ( glob_binding ) ;
374
375
} else if binding. is_ambiguity_recursive ( ) {
375
- resolution. non_glob_binding =
376
- Some ( this. new_warn_ambiguity_binding ( binding ) ) ;
376
+ resolution. glob_binding =
377
+ Some ( this. new_warn_ambiguity_binding ( glob_binding ) ) ;
377
378
}
378
379
}
379
380
( old_glob @ true , false ) | ( old_glob @ false , true ) => {
380
- let ( glob_binding, nonglob_binding ) =
381
+ let ( glob_binding, non_glob_binding ) =
381
382
if old_glob { ( old_binding, binding) } else { ( binding, old_binding) } ;
382
383
if key. ns == MacroNS
383
- && nonglob_binding . expansion != LocalExpnId :: ROOT
384
- && glob_binding. res ( ) != nonglob_binding . res ( )
384
+ && non_glob_binding . expansion != LocalExpnId :: ROOT
385
+ && glob_binding. res ( ) != non_glob_binding . res ( )
385
386
{
386
387
resolution. non_glob_binding = Some ( this. new_ambiguity_binding (
387
388
AmbiguityKind :: GlobVsExpanded ,
388
- nonglob_binding ,
389
+ non_glob_binding ,
389
390
glob_binding,
390
391
false ,
391
392
) ) ;
392
393
} else {
393
- resolution. non_glob_binding = Some ( nonglob_binding ) ;
394
+ resolution. non_glob_binding = Some ( non_glob_binding ) ;
394
395
}
395
396
396
- if let Some ( old_shadowed_glob ) = resolution. glob_binding {
397
- assert ! ( old_shadowed_glob . is_glob_import( ) ) ;
398
- if glob_binding. res ( ) != old_shadowed_glob . res ( ) {
397
+ if let Some ( old_glob ) = resolution. glob_binding {
398
+ assert ! ( old_glob . is_glob_import( ) ) ;
399
+ if glob_binding. res ( ) != old_glob . res ( ) {
399
400
resolution. glob_binding = Some ( this. new_ambiguity_binding (
400
401
AmbiguityKind :: GlobVsGlob ,
401
- old_shadowed_glob ,
402
+ old_glob ,
402
403
glob_binding,
403
404
false ,
404
405
) ) ;
405
- } else if !old_shadowed_glob . vis . is_at_least ( binding. vis , this. tcx ) {
406
+ } else if !old_glob . vis . is_at_least ( binding. vis , this. tcx ) {
406
407
resolution. glob_binding = Some ( glob_binding) ;
407
408
}
408
409
} else {
@@ -414,7 +415,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
414
415
}
415
416
}
416
417
} else {
417
- resolution. non_glob_binding = Some ( binding) ;
418
+ if binding. is_glob_import ( ) {
419
+ resolution. glob_binding = Some ( binding) ;
420
+ } else {
421
+ resolution. non_glob_binding = Some ( binding) ;
422
+ }
418
423
}
419
424
420
425
Ok ( ( ) )
0 commit comments