Skip to content

Commit 9cab720

Browse files
committed
---
yaml --- r: 216932 b: refs/heads/stable c: 69a5c37 h: refs/heads/master v: v3
1 parent 87f3b59 commit 9cab720

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ refs/heads/tmp: 378a370ff2057afeb1eae86eb6e78c476866a4a6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 168615f869ea560aa95e12a3c043c19110368be6
32+
refs/heads/stable: 69a5c379dfbfdb17319eab061bef554845eca407
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375

branches/stable/src/librustc_resolve/resolve_imports.rs

Lines changed: 13 additions & 3 deletions
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)