diff options
| author | Theo Belaire <theo.belaire@gmail.com> | 2015-04-25 15:11:56 -0400 |
|---|---|---|
| committer | Theo Belaire <theo.belaire@gmail.com> | 2015-04-25 15:11:56 -0400 |
| commit | 69a5c379dfbfdb17319eab061bef554845eca407 (patch) | |
| tree | 66a4a0864aa77668fbbbac066220dbc073285f1c | |
| parent | 168615f869ea560aa95e12a3c043c19110368be6 (diff) | |
| download | rust-69a5c379dfbfdb17319eab061bef554845eca407.tar.gz rust-69a5c379dfbfdb17319eab061bef554845eca407.zip | |
Maybe it works
Still compiling, but I think I have it!
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index daffe08fe3a..10068cf373e 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -896,6 +896,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { match target { Some(ref target) if target.shadowable != Shadowable::Always => { + use syntax::ast_map::NodeItem; let ns_word = match namespace { TypeNS => "type", ValueNS => "value", @@ -904,12 +905,21 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { "a {} named `{}` has already been imported \ in this module", ns_word, &token::get_name(name)); + let use_id = import_resolution.id(namespace); + if let NodeItem(item) = self.resolver.ast_map.get(use_id) { + // Assert item.node is ItemUse + // I feel like this should maybe mention the type, + // as it's otherwise a bit of work to look up... + // use syntax::ast::Item; + span_note!(self.resolver.session, item.span, + "Previously import of {} `{}` here", + ns_word, token::get_name(name)); + } + // Also showing the definition is reasonable? if let Some(sp) = target.bindings.span_for_namespace(namespace) { span_note!(self.resolver.session, sp, - "first import of {} `{}` here", + "definition of {} `{}` here", ns_word, token::get_name(name)); - } else { - span_note!(self.resolver.session, import_span, "I can't find where it was previously imported"); } } Some(_) | None => {} |
