Skip to content

Commit 69a5c37

Browse files
committed
Maybe it works
Still compiling, but I think I have it!
1 parent 168615f commit 69a5c37

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/librustc_resolve/resolve_imports.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
896896

897897
match target {
898898
Some(ref target) if target.shadowable != Shadowable::Always => {
899+
use syntax::ast_map::NodeItem;
899900
let ns_word = match namespace {
900901
TypeNS => "type",
901902
ValueNS => "value",
@@ -904,12 +905,21 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
904905
"a {} named `{}` has already been imported \
905906
in this module", ns_word,
906907
&token::get_name(name));
908+
let use_id = import_resolution.id(namespace);
909+
if let NodeItem(item) = self.resolver.ast_map.get(use_id) {
910+
// Assert item.node is ItemUse
911+
// I feel like this should maybe mention the type,
912+
// as it's otherwise a bit of work to look up...
913+
// use syntax::ast::Item;
914+
span_note!(self.resolver.session, item.span,
915+
"Previously import of {} `{}` here",
916+
ns_word, token::get_name(name));
917+
}
918+
// Also showing the definition is reasonable?
907919
if let Some(sp) = target.bindings.span_for_namespace(namespace) {
908920
span_note!(self.resolver.session, sp,
909-
"first import of {} `{}` here",
921+
"definition of {} `{}` here",
910922
ns_word, token::get_name(name));
911-
} else {
912-
span_note!(self.resolver.session, import_span, "I can't find where it was previously imported");
913923
}
914924
}
915925
Some(_) | None => {}

0 commit comments

Comments
 (0)