@@ -251,7 +251,7 @@ pub(crate) struct NameResolution<'ra> {
251
251
impl < ' ra > NameResolution < ' ra > {
252
252
/// Returns the binding for the name if it is known or None if it not known.
253
253
pub ( crate ) fn binding ( & self ) -> Option < NameBinding < ' ra > > {
254
- self . late_binding ( ) . and_then ( |binding| {
254
+ self . best_binding ( ) . and_then ( |binding| {
255
255
if !binding. is_glob_import ( ) || self . single_imports . is_empty ( ) {
256
256
Some ( binding)
257
257
} else {
@@ -260,7 +260,7 @@ impl<'ra> NameResolution<'ra> {
260
260
} )
261
261
}
262
262
263
- pub ( crate ) fn late_binding ( & self ) -> Option < NameBinding < ' ra > > {
263
+ pub ( crate ) fn best_binding ( & self ) -> Option < NameBinding < ' ra > > {
264
264
self . non_glob_binding . or ( self . glob_binding )
265
265
}
266
266
}
@@ -343,7 +343,7 @@ 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. late_binding ( ) {
346
+ if let Some ( old_binding) = resolution. best_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 ( ( ) ) ;
@@ -394,16 +394,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
394
394
resolution. non_glob_binding = Some ( non_glob_binding) ;
395
395
}
396
396
397
- if let Some ( old_glob ) = resolution. glob_binding {
398
- assert ! ( old_glob . is_glob_import( ) ) ;
399
- if glob_binding. res ( ) != old_glob . res ( ) {
397
+ if let Some ( old_glob_binding ) = resolution. glob_binding {
398
+ assert ! ( old_glob_binding . is_glob_import( ) ) ;
399
+ if glob_binding. res ( ) != old_glob_binding . res ( ) {
400
400
resolution. glob_binding = Some ( this. new_ambiguity_binding (
401
401
AmbiguityKind :: GlobVsGlob ,
402
- old_glob ,
402
+ old_glob_binding ,
403
403
glob_binding,
404
404
false ,
405
405
) ) ;
406
- } else if !old_glob . vis . is_at_least ( binding. vis , this. tcx ) {
406
+ } else if !old_glob_binding . vis . is_at_least ( binding. vis , this. tcx ) {
407
407
resolution. glob_binding = Some ( glob_binding) ;
408
408
}
409
409
} else {
@@ -639,7 +639,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
639
639
for ( key, resolution) in self . resolutions ( * module) . borrow ( ) . iter ( ) {
640
640
let resolution = resolution. borrow ( ) ;
641
641
642
- let Some ( binding) = resolution. late_binding ( ) else { continue } ;
642
+ let Some ( binding) = resolution. best_binding ( ) else { continue } ;
643
643
644
644
if let NameBindingKind :: Import { import, .. } = binding. kind
645
645
&& let Some ( ( amb_binding, _) ) = binding. ambiguity
@@ -659,7 +659,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
659
659
) ;
660
660
}
661
661
662
- if let Some ( glob_binding) = resolution. glob_binding {
662
+ if let Some ( glob_binding) = resolution. glob_binding
663
+ && resolution. non_glob_binding . is_some ( )
664
+ {
663
665
if binding. res ( ) != Res :: Err
664
666
&& glob_binding. res ( ) != Res :: Err
665
667
&& let NameBindingKind :: Import { import : glob_import, .. } =
@@ -1191,7 +1193,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1191
1193
} // Never suggest the same name
1192
1194
match * resolution. borrow ( ) {
1193
1195
ref resolution
1194
- if let Some ( name_binding) = resolution. late_binding ( ) =>
1196
+ if let Some ( name_binding) = resolution. best_binding ( ) =>
1195
1197
{
1196
1198
match name_binding. kind {
1197
1199
NameBindingKind :: Import { binding, .. } => {
0 commit comments