@@ -325,7 +325,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
325325 self . arenas . alloc_name_binding ( NameBindingData {
326326 kind : NameBindingKind :: Import { binding, import } ,
327327 ambiguity : None ,
328- warn_ambiguity : false ,
329328 span : import. span ,
330329 vis,
331330 expansion : import. parent_scope . expansion ,
@@ -339,7 +338,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
339338 ident : Ident ,
340339 ns : Namespace ,
341340 binding : NameBinding < ' ra > ,
342- warn_ambiguity : bool ,
343341 ) -> Result < ( ) , NameBinding < ' ra > > {
344342 let res = binding. res ( ) ;
345343 self . check_reserved_macro_name ( ident, res) ;
@@ -351,7 +349,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
351349 module. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
352350 module. underscore_disambiguator . get ( )
353351 } ) ;
354- self . update_local_resolution ( module, key, warn_ambiguity , |this, resolution| {
352+ self . update_local_resolution ( module, key, |this, resolution| {
355353 if let Some ( old_binding) = resolution. best_binding ( ) {
356354 if res == Res :: Err && old_binding. res ( ) != Res :: Err {
357355 // Do not override real bindings with `Res::Err`s from error recovery.
@@ -360,30 +358,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
360358 match ( old_binding. is_glob_import ( ) , binding. is_glob_import ( ) ) {
361359 ( true , true ) => {
362360 let ( glob_binding, old_glob_binding) = ( binding, old_binding) ;
363- // FIXME: remove `!binding.is_ambiguity_recursive()` after delete the warning ambiguity.
364- if !binding. is_ambiguity_recursive ( )
365- && let NameBindingKind :: Import { import : old_import, .. } =
366- old_glob_binding. kind
367- && let NameBindingKind :: Import { import, .. } = glob_binding. kind
368- && old_import == import
369- {
370- // When imported from the same glob-import statement, we should replace
371- // `old_glob_binding` with `glob_binding`, regardless of whether
372- // they have the same resolution or not.
373- resolution. glob_binding = Some ( glob_binding) ;
374- } else if res != old_glob_binding. res ( ) {
361+ if res != old_glob_binding. res ( ) {
375362 resolution. glob_binding = Some ( this. new_ambiguity_binding (
376363 AmbiguityKind :: GlobVsGlob ,
377364 old_glob_binding,
378365 glob_binding,
379- warn_ambiguity,
380366 ) ) ;
381- } else if !old_binding. vis . is_at_least ( binding. vis , this. tcx ) {
367+ } else if !old_glob_binding. vis . is_at_least ( glob_binding. vis , this. tcx )
368+ || glob_binding. is_ambiguity_recursive ( )
369+ {
382370 // We are glob-importing the same item but with greater visibility.
383371 resolution. glob_binding = Some ( glob_binding) ;
384- } else if binding. is_ambiguity_recursive ( ) {
385- resolution. glob_binding =
386- Some ( this. new_warn_ambiguity_binding ( glob_binding) ) ;
387372 }
388373 }
389374 ( old_glob @ true , false ) | ( old_glob @ false , true ) => {
@@ -397,7 +382,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
397382 AmbiguityKind :: GlobVsExpanded ,
398383 non_glob_binding,
399384 glob_binding,
400- false ,
401385 ) ) ;
402386 } else {
403387 resolution. non_glob_binding = Some ( non_glob_binding) ;
@@ -410,9 +394,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
410394 AmbiguityKind :: GlobVsGlob ,
411395 old_glob_binding,
412396 glob_binding,
413- false ,
414397 ) ) ;
415- } else if !old_glob_binding. vis . is_at_least ( binding. vis , this. tcx ) {
398+ } else if !old_glob_binding. vis . is_at_least ( glob_binding. vis , this. tcx )
399+ || glob_binding. is_ambiguity_recursive ( )
400+ {
401+ // We are glob-importing the same item but with greater visibility.
416402 resolution. glob_binding = Some ( glob_binding) ;
417403 }
418404 } else {
@@ -440,33 +426,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
440426 ambiguity_kind : AmbiguityKind ,
441427 primary_binding : NameBinding < ' ra > ,
442428 secondary_binding : NameBinding < ' ra > ,
443- warn_ambiguity : bool ,
444429 ) -> NameBinding < ' ra > {
445- let ambiguity = Some ( ( secondary_binding, ambiguity_kind) ) ;
446- let data = NameBindingData { ambiguity, warn_ambiguity , ..* primary_binding } ;
430+ let ambiguity = Some ( ( secondary_binding, ambiguity_kind, false ) ) ;
431+ let data = NameBindingData { ambiguity, ..* primary_binding } ;
447432 self . arenas . alloc_name_binding ( data)
448433 }
449434
450- fn new_warn_ambiguity_binding ( & self , binding : NameBinding < ' ra > ) -> NameBinding < ' ra > {
451- assert ! ( binding. is_ambiguity_recursive( ) ) ;
452- self . arenas . alloc_name_binding ( NameBindingData { warn_ambiguity : true , ..* binding } )
453- }
454-
455435 // Use `f` to mutate the resolution of the name in the module.
456436 // If the resolution becomes a success, define it in the module's glob importers.
457- fn update_local_resolution < T , F > (
458- & mut self ,
459- module : Module < ' ra > ,
460- key : BindingKey ,
461- warn_ambiguity : bool ,
462- f : F ,
463- ) -> T
437+ fn update_local_resolution < T , F > ( & mut self , module : Module < ' ra > , key : BindingKey , f : F ) -> T
464438 where
465439 F : FnOnce ( & Resolver < ' ra , ' tcx > , & mut NameResolution < ' ra > ) -> T ,
466440 {
467441 // Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
468442 // during which the resolution might end up getting re-defined via a glob cycle.
469- let ( binding, t, warn_ambiguity ) = {
443+ let ( binding, t) = {
470444 let resolution = & mut * self . resolution_or_default ( module, key) . borrow_mut_unchecked ( ) ;
471445 let old_binding = resolution. binding ( ) ;
472446
@@ -475,7 +449,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
475449 if let Some ( binding) = resolution. binding ( )
476450 && old_binding != Some ( binding)
477451 {
478- ( binding, t, warn_ambiguity || old_binding . is_some ( ) )
452+ ( binding, t)
479453 } else {
480454 return t;
481455 }
@@ -500,7 +474,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
500474 ident. 0 ,
501475 key. ns ,
502476 imported_binding,
503- warn_ambiguity,
504477 ) ;
505478 }
506479 }
@@ -521,11 +494,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
521494 let dummy_binding = self . import ( dummy_binding, import) ;
522495 self . per_ns ( |this, ns| {
523496 let module = import. parent_scope . module ;
524- let _ = this. try_define_local ( module, target, ns, dummy_binding, false ) ;
497+ let _ = this. try_define_local ( module, target, ns, dummy_binding) ;
525498 // Don't remove underscores from `single_imports`, they were never added.
526499 if target. name != kw:: Underscore {
527500 let key = BindingKey :: new ( target, ns) ;
528- this. update_local_resolution ( module, key, false , |_, resolution| {
501+ this. update_local_resolution ( module, key, |_, resolution| {
529502 resolution. single_imports . swap_remove ( & import) ;
530503 } )
531504 }
@@ -658,7 +631,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
658631 let Some ( binding) = resolution. best_binding ( ) else { continue } ;
659632
660633 if let NameBindingKind :: Import { import, .. } = binding. kind
661- && let Some ( ( amb_binding, _ ) ) = binding. ambiguity
634+ && let Some ( ( amb_binding, .. ) ) = binding. ambiguity
662635 && binding. res ( ) != Res :: Err
663636 && exported_ambiguities. contains ( & binding)
664637 {
@@ -917,7 +890,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
917890 this. get_mut_unchecked ( ) . update_local_resolution (
918891 parent,
919892 key,
920- false ,
921893 |_, resolution| {
922894 resolution. single_imports . swap_remove ( & import) ;
923895 } ,
@@ -1523,16 +1495,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15231495 } ;
15241496 if self . is_accessible_from ( binding. vis , scope) {
15251497 let imported_binding = self . import ( binding, import) ;
1526- let warn_ambiguity = self
1527- . resolution ( import. parent_scope . module , key)
1528- . and_then ( |r| r. binding ( ) )
1529- . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
15301498 let _ = self . try_define_local (
15311499 import. parent_scope . module ,
15321500 key. ident . 0 ,
15331501 key. ns ,
15341502 imported_binding,
1535- warn_ambiguity,
15361503 ) ;
15371504 }
15381505 }
0 commit comments