@@ -4,7 +4,10 @@ use crate::diagnostics::{import_candidates, Suggestion};
4
4
use crate :: Determinacy :: { self , * } ;
5
5
use crate :: Namespace :: * ;
6
6
use 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
+ } ;
8
11
use crate :: { Finalize , Module , ModuleOrUniformRoot , ParentScope , PerNS , ScopeSet } ;
9
12
use crate :: { NameBinding , NameBindingKind , PathResult } ;
10
13
@@ -791,7 +794,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
791
794
match binding {
792
795
Ok ( binding) => {
793
796
// 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| {
795
798
all_ns_err = false ;
796
799
if let Some ( target_binding) = target_bindings[ ns] . get ( ) {
797
800
if target. name == kw:: Underscore
@@ -805,12 +808,20 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
805
808
) ;
806
809
}
807
810
}
808
- initial_binding. res ( )
811
+ initial_binding
809
812
} ) ;
810
813
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 ( ) ;
812
816
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
+ } ) ;
814
825
}
815
826
} else if res != Res :: Err
816
827
&& this. ambiguity_errors . is_empty ( )
0 commit comments