@@ -4,7 +4,10 @@ use crate::diagnostics::{import_candidates, Suggestion};
44use crate :: Determinacy :: { self , * } ;
55use crate :: Namespace :: * ;
66use crate :: { module_to_string, names_to_string, ImportSuggestion } ;
7- use crate :: { AmbiguityKind , BindingKey , ModuleKind , ResolutionError , Resolver , Segment } ;
7+ use crate :: {
8+ AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , BindingKey , ModuleKind , ResolutionError ,
9+ Resolver , Segment ,
10+ } ;
811use crate :: { Finalize , Module , ModuleOrUniformRoot , ParentScope , PerNS , ScopeSet } ;
912use crate :: { NameBinding , NameBindingKind , PathResult } ;
1013
@@ -791,7 +794,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
791794 match binding {
792795 Ok ( binding) => {
793796 // Consistency checks, analogous to `finalize_macro_resolutions`.
794- let initial_res = source_bindings[ ns] . get ( ) . map ( |initial_binding| {
797+ let initial_binding = source_bindings[ ns] . get ( ) . map ( |initial_binding| {
795798 all_ns_err = false ;
796799 if let Some ( target_binding) = target_bindings[ ns] . get ( ) {
797800 if target. name == kw:: Underscore
@@ -805,12 +808,20 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
805808 ) ;
806809 }
807810 }
808- initial_binding. res ( )
811+ initial_binding
809812 } ) ;
810813 let res = binding. res ( ) ;
811- if let Ok ( initial_res) = initial_res {
814+ if let Ok ( initial_binding) = initial_binding {
815+ let initial_res = initial_binding. res ( ) ;
812816 if res != initial_res && this. ambiguity_errors . is_empty ( ) {
813- span_bug ! ( import. span, "inconsistent resolution for an import" ) ;
817+ this. ambiguity_errors . push ( AmbiguityError {
818+ kind : AmbiguityKind :: Import ,
819+ ident,
820+ b1 : initial_binding,
821+ b2 : binding,
822+ misc1 : AmbiguityErrorMisc :: None ,
823+ misc2 : AmbiguityErrorMisc :: None ,
824+ } ) ;
814825 }
815826 } else if res != Res :: Err
816827 && this. ambiguity_errors . is_empty ( )
0 commit comments