@@ -326,7 +326,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
326326 self . arenas . alloc_name_binding ( NameBindingData {
327327 kind : NameBindingKind :: Import { binding, import } ,
328328 ambiguity : None ,
329- warn_ambiguity : false ,
330329 span : import. span ,
331330 vis,
332331 expansion : import. parent_scope . expansion ,
@@ -340,7 +339,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
340339 ident : Ident ,
341340 ns : Namespace ,
342341 binding : NameBinding < ' ra > ,
343- warn_ambiguity : bool ,
344342 ) -> Result < ( ) , NameBinding < ' ra > > {
345343 let res = binding. res ( ) ;
346344 self . check_reserved_macro_name ( ident, res) ;
@@ -352,7 +350,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
352350 module. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
353351 module. underscore_disambiguator . get ( )
354352 } ) ;
355- self . update_local_resolution ( module, key, warn_ambiguity , |this, resolution| {
353+ self . update_local_resolution ( module, key, |this, resolution| {
356354 if let Some ( old_binding) = resolution. best_binding ( ) {
357355 if res == Res :: Err && old_binding. res ( ) != Res :: Err {
358356 // Do not override real bindings with `Res::Err`s from error recovery.
@@ -361,30 +359,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
361359 match ( old_binding. is_glob_import ( ) , binding. is_glob_import ( ) ) {
362360 ( true , true ) => {
363361 let ( glob_binding, old_glob_binding) = ( binding, old_binding) ;
364- // FIXME: remove `!binding.is_ambiguity_recursive()` after delete the warning ambiguity.
365- if !binding. is_ambiguity_recursive ( )
366- && let NameBindingKind :: Import { import : old_import, .. } =
367- old_glob_binding. kind
368- && let NameBindingKind :: Import { import, .. } = glob_binding. kind
369- && old_import == import
370- {
371- // When imported from the same glob-import statement, we should replace
372- // `old_glob_binding` with `glob_binding`, regardless of whether
373- // they have the same resolution or not.
374- resolution. glob_binding = Some ( glob_binding) ;
375- } else if res != old_glob_binding. res ( ) {
362+ if res != old_glob_binding. res ( ) {
376363 resolution. glob_binding = Some ( this. new_ambiguity_binding (
377364 AmbiguityKind :: GlobVsGlob ,
378365 old_glob_binding,
379366 glob_binding,
380- warn_ambiguity,
381367 ) ) ;
382- } else if !old_binding. vis . is_at_least ( binding. vis , this. tcx ) {
368+ } else if !old_glob_binding. vis . is_at_least ( glob_binding. vis , this. tcx )
369+ || glob_binding. is_ambiguity_recursive ( )
370+ {
383371 // We are glob-importing the same item but with greater visibility.
384372 resolution. glob_binding = Some ( glob_binding) ;
385- } else if binding. is_ambiguity_recursive ( ) {
386- resolution. glob_binding =
387- Some ( this. new_warn_ambiguity_binding ( glob_binding) ) ;
388373 }
389374 }
390375 ( old_glob @ true , false ) | ( old_glob @ false , true ) => {
@@ -398,7 +383,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
398383 AmbiguityKind :: GlobVsExpanded ,
399384 non_glob_binding,
400385 glob_binding,
401- false ,
402386 ) ) ;
403387 } else {
404388 resolution. non_glob_binding = Some ( non_glob_binding) ;
@@ -411,9 +395,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
411395 AmbiguityKind :: GlobVsGlob ,
412396 old_glob_binding,
413397 glob_binding,
414- false ,
415398 ) ) ;
416- } else if !old_glob_binding. vis . is_at_least ( binding. vis , this. tcx ) {
399+ } else if !old_glob_binding. vis . is_at_least ( glob_binding. vis , this. tcx )
400+ || glob_binding. is_ambiguity_recursive ( )
401+ {
402+ // We are glob-importing the same item but with greater visibility.
417403 resolution. glob_binding = Some ( glob_binding) ;
418404 }
419405 } else {
@@ -441,33 +427,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
441427 ambiguity_kind : AmbiguityKind ,
442428 primary_binding : NameBinding < ' ra > ,
443429 secondary_binding : NameBinding < ' ra > ,
444- warn_ambiguity : bool ,
445430 ) -> NameBinding < ' ra > {
446431 let ambiguity = Some ( ( secondary_binding, ambiguity_kind) ) ;
447- let data = NameBindingData { ambiguity, warn_ambiguity , ..* primary_binding } ;
432+ let data = NameBindingData { ambiguity, ..* primary_binding } ;
448433 self . arenas . alloc_name_binding ( data)
449434 }
450435
451- fn new_warn_ambiguity_binding ( & self , binding : NameBinding < ' ra > ) -> NameBinding < ' ra > {
452- assert ! ( binding. is_ambiguity_recursive( ) ) ;
453- self . arenas . alloc_name_binding ( NameBindingData { warn_ambiguity : true , ..* binding } )
454- }
455-
456436 // Use `f` to mutate the resolution of the name in the module.
457437 // If the resolution becomes a success, define it in the module's glob importers.
458- fn update_local_resolution < T , F > (
459- & mut self ,
460- module : Module < ' ra > ,
461- key : BindingKey ,
462- warn_ambiguity : bool ,
463- f : F ,
464- ) -> T
438+ fn update_local_resolution < T , F > ( & mut self , module : Module < ' ra > , key : BindingKey , f : F ) -> T
465439 where
466440 F : FnOnce ( & Resolver < ' ra , ' tcx > , & mut NameResolution < ' ra > ) -> T ,
467441 {
468442 // Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
469443 // during which the resolution might end up getting re-defined via a glob cycle.
470- let ( binding, t, warn_ambiguity ) = {
444+ let ( binding, t) = {
471445 let resolution = & mut * self . resolution_or_default ( module, key) . borrow_mut_unchecked ( ) ;
472446 let old_binding = resolution. binding ( ) ;
473447
@@ -476,7 +450,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
476450 if let Some ( binding) = resolution. binding ( )
477451 && old_binding != Some ( binding)
478452 {
479- ( binding, t, warn_ambiguity || old_binding . is_some ( ) )
453+ ( binding, t)
480454 } else {
481455 return t;
482456 }
@@ -501,7 +475,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
501475 ident. 0 ,
502476 key. ns ,
503477 imported_binding,
504- warn_ambiguity,
505478 ) ;
506479 }
507480 }
@@ -522,11 +495,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
522495 let dummy_binding = self . import ( dummy_binding, import) ;
523496 self . per_ns ( |this, ns| {
524497 let module = import. parent_scope . module ;
525- let _ = this. try_define_local ( module, target, ns, dummy_binding, false ) ;
498+ let _ = this. try_define_local ( module, target, ns, dummy_binding) ;
526499 // Don't remove underscores from `single_imports`, they were never added.
527500 if target. name != kw:: Underscore {
528501 let key = BindingKey :: new ( target, ns) ;
529- this. update_local_resolution ( module, key, false , |_, resolution| {
502+ this. update_local_resolution ( module, key, |_, resolution| {
530503 resolution. single_imports . swap_remove ( & import) ;
531504 } )
532505 }
@@ -916,7 +889,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
916889 this. get_mut_unchecked ( ) . update_local_resolution (
917890 parent,
918891 key,
919- false ,
920892 |_, resolution| {
921893 resolution. single_imports . swap_remove ( & import) ;
922894 } ,
@@ -945,8 +917,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
945917 ImportKind :: Single { bindings, .. } => bindings[ TypeNS ] . get ( ) . binding ( ) ,
946918 _ => None ,
947919 } ;
948- let ambiguity_errors_len =
949- |errors : & Vec < AmbiguityError < ' _ > > | errors. iter ( ) . filter ( |error| !error. warning ) . count ( ) ;
920+ let ambiguity_errors_len = |errors : & Vec < AmbiguityError < ' _ > > | errors. iter ( ) . count ( ) ;
950921 let prev_ambiguity_errors_len = ambiguity_errors_len ( & self . ambiguity_errors ) ;
951922 let finalize = Finalize :: with_root_span ( import. root_id , import. span , import. root_span ) ;
952923
@@ -1160,9 +1131,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11601131 initial_binding. res ( )
11611132 } ) ;
11621133 let res = binding. res ( ) ;
1163- let has_ambiguity_error =
1164- this. ambiguity_errors . iter ( ) . any ( |error| !error. warning ) ;
1165- if res == Res :: Err || has_ambiguity_error {
1134+ if res == Res :: Err || !this. ambiguity_errors . is_empty ( ) {
11661135 this. dcx ( )
11671136 . span_delayed_bug ( import. span , "some error happened for an import" ) ;
11681137 return ;
@@ -1520,16 +1489,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15201489 } ;
15211490 if self . is_accessible_from ( binding. vis , scope) {
15221491 let imported_binding = self . import ( binding, import) ;
1523- let warn_ambiguity = self
1524- . resolution ( import. parent_scope . module , key)
1525- . and_then ( |r| r. binding ( ) )
1526- . is_some_and ( |binding| binding. warn_ambiguity_recursive ( ) ) ;
15271492 let _ = self . try_define_local (
15281493 import. parent_scope . module ,
15291494 key. ident . 0 ,
15301495 key. ns ,
15311496 imported_binding,
1532- warn_ambiguity,
15331497 ) ;
15341498 }
15351499 }
@@ -1554,8 +1518,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15541518
15551519 module. for_each_child ( self , |this, ident, _, binding| {
15561520 let res = binding. res ( ) . expect_non_local ( ) ;
1557- let error_ambiguity = binding. is_ambiguity_recursive ( ) && !binding. warn_ambiguity ;
1558- if res != def:: Res :: Err && !error_ambiguity {
1521+ if res != def:: Res :: Err && !binding. is_ambiguity_recursive ( ) {
15591522 let mut reexport_chain = SmallVec :: new ( ) ;
15601523 let mut next_binding = binding;
15611524 while let NameBindingKind :: Import { binding, import, .. } = next_binding. kind {
0 commit comments