Fixed types, and slimmed down code
I don't this we need to print the definition of the imported value too, though it's quite possible.
This commit is contained in:
parent
69a5c379df
commit
5c05278fec
2 changed files with 8 additions and 16 deletions
|
|
@ -897,6 +897,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",
|
||||
|
|
@ -907,19 +908,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
|
|||
&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;
|
||||
// item is 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,
|
||||
"definition of {} `{}` here",
|
||||
ns_word, token::get_name(name));
|
||||
"previous import of `{}` here",
|
||||
token::get_name(name));
|
||||
}
|
||||
}
|
||||
Some(_) | None => {}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
|
||||
mod sub1 {
|
||||
fn foo() {} // Implementation 1
|
||||
fn foo() {} // implementation 1
|
||||
}
|
||||
|
||||
mod sub2 {
|
||||
fn foo() {} // Implementation 2
|
||||
fn foo() {} // implementation 2
|
||||
}
|
||||
|
||||
use sub1::foo; //~ NOTE first imported here
|
||||
use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252]
|
||||
use sub1::foo; //~ note previous import of `foo` here
|
||||
use sub2::foo; //~ error a value named `foo` has already been imported in this module [e0252]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue