@@ -618,7 +618,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
618
618
namespace_name,
619
619
name_bindings. def_for_namespace( namespace) ) ;
620
620
self . check_for_conflicting_import (
621
- & import_resolution. target_for_namespace ( namespace ) ,
621
+ & import_resolution,
622
622
directive. span ,
623
623
target,
624
624
namespace) ;
@@ -755,7 +755,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
755
755
// Continue.
756
756
}
757
757
Some ( ref value_target) => {
758
- self . check_for_conflicting_import ( & dest_import_resolution. value_target ,
758
+ self . check_for_conflicting_import ( & dest_import_resolution,
759
759
import_directive. span ,
760
760
* ident,
761
761
ValueNS ) ;
@@ -767,7 +767,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
767
767
// Continue.
768
768
}
769
769
Some ( ref type_target) => {
770
- self . check_for_conflicting_import ( & dest_import_resolution. type_target ,
770
+ self . check_for_conflicting_import ( & dest_import_resolution,
771
771
import_directive. span ,
772
772
* ident,
773
773
TypeNS ) ;
@@ -887,24 +887,31 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
887
887
888
888
/// Checks that imported names and items don't have the same name.
889
889
fn check_for_conflicting_import ( & mut self ,
890
- target : & Option < Target > ,
890
+ import_resolution : & ImportResolution ,
891
891
import_span : Span ,
892
892
name : Name ,
893
893
namespace : Namespace ) {
894
+ let target = import_resolution. target_for_namespace ( namespace) ;
894
895
debug ! ( "check_for_conflicting_import: {}; target exists: {}" ,
895
896
& token:: get_name( name) ,
896
897
target. is_some( ) ) ;
897
898
898
- match * target {
899
+ match target {
899
900
Some ( ref target) if target. shadowable != Shadowable :: Always => {
900
- let msg = format ! ( "a {} named `{}` has already been imported \
901
- in this module",
902
- match namespace {
903
- TypeNS => "type" ,
904
- ValueNS => "value" ,
905
- } ,
901
+ let ns_word = match namespace {
902
+ TypeNS => "type" ,
903
+ ValueNS => "value" ,
904
+ } ;
905
+ span_err ! ( self . resolver. session, import_span, E0252 ,
906
+ "a {} named `{}` has already been imported \
907
+ in this module", ns_word,
906
908
& token:: get_name( name) ) ;
907
- span_err ! ( self . resolver. session, import_span, E0252 , "{}" , & msg[ ..] ) ;
909
+ let use_id = import_resolution. id ( namespace) ;
910
+ let item = self . resolver . ast_map . expect_item ( use_id) ;
911
+ // item is syntax::ast::Item;
912
+ span_note ! ( self . resolver. session, item. span,
913
+ "previous import of `{}` here" ,
914
+ token:: get_name( name) ) ;
908
915
}
909
916
Some ( _) | None => { }
910
917
}
0 commit comments