From 4209f948b175b61056560f91dd0bd1719ba61deb Mon Sep 17 00:00:00 2001 From: crypto-universe Date: Thu, 11 Aug 2016 01:52:44 +0200 Subject: [PATCH 1/2] Add label to E0254 This issue #35513 is a part of #35233. r? @jonathandturner --- src/librustc_resolve/lib.rs | 7 +++++-- src/test/compile-fail/E0254.rs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 860e569ba7e5e..896b4a1847de9 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3370,8 +3370,11 @@ impl<'a> Resolver<'a> { let mut err = match (old_binding.is_extern_crate(), binding.is_extern_crate()) { (true, true) => struct_span_err!(self.session, span, E0259, "{}", msg), - (true, _) | (_, true) if binding.is_import() || old_binding.is_import() => - struct_span_err!(self.session, span, E0254, "{}", msg), + (true, _) | (_, true) if binding.is_import() || old_binding.is_import() => { + let mut e = struct_span_err!(self.session, span, E0254, "{}", msg); + e.span_label(span, &"already imported"); + e + }, (true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg), _ => match (old_binding.is_import(), binding.is_import()) { (false, false) => struct_span_err!(self.session, span, E0428, "{}", msg), diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs index 28f9aea96572c..e6916f377ea12 100644 --- a/src/test/compile-fail/E0254.rs +++ b/src/test/compile-fail/E0254.rs @@ -9,6 +9,7 @@ // except according to those terms. extern crate collections; +//~^ NOTE previous import of `collections` here mod foo { pub trait collections { @@ -16,6 +17,8 @@ mod foo { } } -use foo::collections; //~ ERROR E0254 +use foo::collections; +//~^ ERROR E0254 +//~| NOTE already imported fn main() {} From c761184d1de1fec8b49ce1d97e63b5bacb15b7b0 Mon Sep 17 00:00:00 2001 From: crypto-universe Date: Thu, 11 Aug 2016 21:08:36 +0200 Subject: [PATCH 2/2] Fix tidy tests --- src/test/compile-fail/E0254.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs index e6916f377ea12..3e4b7b9cad2d4 100644 --- a/src/test/compile-fail/E0254.rs +++ b/src/test/compile-fail/E0254.rs @@ -17,7 +17,7 @@ mod foo { } } -use foo::collections; +use foo::collections; //~^ ERROR E0254 //~| NOTE already imported