@@ -872,6 +872,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
872
872
/// consolidate multiple unresolved import errors into a single diagnostic.
873
873
fn finalize_import ( & mut self , import : & ' b Import < ' b > ) -> Option < UnresolvedImportError > {
874
874
let orig_vis = import. vis . replace ( ty:: Visibility :: Invisible ) ;
875
+ let orig_unusable_binding = match & import. kind {
876
+ ImportKind :: Single { target_bindings, .. } => {
877
+ Some ( mem:: replace ( & mut self . r . unusable_binding , target_bindings[ TypeNS ] . get ( ) ) )
878
+ }
879
+ _ => None ,
880
+ } ;
875
881
let prev_ambiguity_errors_len = self . r . ambiguity_errors . len ( ) ;
876
882
let path_res = self . r . resolve_path (
877
883
& import. module_path ,
@@ -882,6 +888,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
882
888
import. crate_lint ( ) ,
883
889
) ;
884
890
let no_ambiguity = self . r . ambiguity_errors . len ( ) == prev_ambiguity_errors_len;
891
+ if let Some ( orig_unusable_binding) = orig_unusable_binding {
892
+ self . r . unusable_binding = orig_unusable_binding;
893
+ }
885
894
import. vis . set ( orig_vis) ;
886
895
if let PathResult :: Failed { .. } | PathResult :: NonModule ( ..) = path_res {
887
896
// Consider erroneous imports used to avoid duplicate diagnostics.
@@ -892,8 +901,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
892
901
// Consistency checks, analogous to `finalize_macro_resolutions`.
893
902
if let Some ( initial_module) = import. imported_module . get ( ) {
894
903
if !ModuleOrUniformRoot :: same_def ( module, initial_module) && no_ambiguity {
895
- let msg = "inconsistent resolution for an import" ;
896
- self . r . session . span_err ( import. span , msg) ;
904
+ span_bug ! ( import. span, "inconsistent resolution for an import" ) ;
897
905
}
898
906
} else if self . r . privacy_errors . is_empty ( ) {
899
907
let msg = "cannot determine resolution for the import" ;
@@ -913,6 +921,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
913
921
}
914
922
PathResult :: Failed { is_error_from_last_segment : true , span, label, suggestion } => {
915
923
if no_ambiguity {
924
+ assert ! ( import. imported_module. get( ) . is_none( ) ) ;
916
925
let err = match self . make_path_suggestion (
917
926
span,
918
927
import. module_path . clone ( ) ,
0 commit comments