@@ -251,7 +251,7 @@ pub(crate) struct NameResolution<'ra> {
251251impl < ' ra > NameResolution < ' ra > {
252252 /// Returns the binding for the name if it is known or None if it not known.
253253 pub ( crate ) fn binding ( & self ) -> Option < NameBinding < ' ra > > {
254- self . late_binding ( ) . and_then ( |binding| {
254+ self . best_binding ( ) . and_then ( |binding| {
255255 if !binding. is_glob_import ( ) || self . single_imports . is_empty ( ) {
256256 Some ( binding)
257257 } else {
@@ -260,7 +260,7 @@ impl<'ra> NameResolution<'ra> {
260260 } )
261261 }
262262
263- pub ( crate ) fn late_binding ( & self ) -> Option < NameBinding < ' ra > > {
263+ pub ( crate ) fn best_binding ( & self ) -> Option < NameBinding < ' ra > > {
264264 self . non_glob_binding . or ( self . glob_binding )
265265 }
266266}
@@ -343,7 +343,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
343343 self . check_reserved_macro_name ( key. ident , res) ;
344344 self . set_binding_parent_module ( binding, module) ;
345345 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 ( ) {
347347 if res == Res :: Err && old_binding. res ( ) != Res :: Err {
348348 // Do not override real bindings with `Res::Err`s from error recovery.
349349 return Ok ( ( ) ) ;
@@ -394,16 +394,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
394394 resolution. non_glob_binding = Some ( non_glob_binding) ;
395395 }
396396
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 ( ) {
400400 resolution. glob_binding = Some ( this. new_ambiguity_binding (
401401 AmbiguityKind :: GlobVsGlob ,
402- old_glob ,
402+ old_glob_binding ,
403403 glob_binding,
404404 false ,
405405 ) ) ;
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 ) {
407407 resolution. glob_binding = Some ( glob_binding) ;
408408 }
409409 } else {
@@ -639,7 +639,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
639639 for ( key, resolution) in self . resolutions ( * module) . borrow ( ) . iter ( ) {
640640 let resolution = resolution. borrow ( ) ;
641641
642- let Some ( binding) = resolution. late_binding ( ) else { continue } ;
642+ let Some ( binding) = resolution. best_binding ( ) else { continue } ;
643643
644644 if let NameBindingKind :: Import { import, .. } = binding. kind
645645 && let Some ( ( amb_binding, _) ) = binding. ambiguity
@@ -659,7 +659,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
659659 ) ;
660660 }
661661
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+ {
663665 if binding. res ( ) != Res :: Err
664666 && glob_binding. res ( ) != Res :: Err
665667 && let NameBindingKind :: Import { import : glob_import, .. } =
@@ -1191,7 +1193,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11911193 } // Never suggest the same name
11921194 match * resolution. borrow ( ) {
11931195 ref resolution
1194- if let Some ( name_binding) = resolution. late_binding ( ) =>
1196+ if let Some ( name_binding) = resolution. best_binding ( ) =>
11951197 {
11961198 match name_binding. kind {
11971199 NameBindingKind :: Import { binding, .. } => {
0 commit comments