Skip to content

Commit 5c05278

Browse files
committed
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.
1 parent 69a5c37 commit 5c05278

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/librustc_resolve/resolve_imports.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
897897
match target {
898898
Some(ref target) if target.shadowable != Shadowable::Always => {
899899
use syntax::ast_map::NodeItem;
900+
900901
let ns_word = match namespace {
901902
TypeNS => "type",
902903
ValueNS => "value",
@@ -907,19 +908,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
907908
&token::get_name(name));
908909
let use_id = import_resolution.id(namespace);
909910
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;
911+
// item is syntax::ast::Item;
914912
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?
919-
if let Some(sp) = target.bindings.span_for_namespace(namespace) {
920-
span_note!(self.resolver.session, sp,
921-
"definition of {} `{}` here",
922-
ns_word, token::get_name(name));
913+
"previous import of `{}` here",
914+
token::get_name(name));
923915
}
924916
}
925917
Some(_) | None => {}

src/test/compile-fail/double-import.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313

1414
mod sub1 {
15-
fn foo() {} // Implementation 1
15+
fn foo() {} // implementation 1
1616
}
1717

1818
mod sub2 {
19-
fn foo() {} // Implementation 2
19+
fn foo() {} // implementation 2
2020
}
2121

22-
use sub1::foo; //~ NOTE first imported here
23-
use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252]
22+
use sub1::foo; //~ note previous import of `foo` here
23+
use sub2::foo; //~ error a value named `foo` has already been imported in this module [e0252]
2424

2525
fn main() {}

0 commit comments

Comments
 (0)