about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-05 16:12:59 +0200
committerGitHub <noreply@github.com>2016-08-05 16:12:59 +0200
commit31da06bebb721b7c1d93bf7e4802b95852acca4f (patch)
treed5832811f5b3a0ab04b5abc31db0b0652f834054
parent6597a28144cb18efbdf605f17c83f14f4e63a52a (diff)
parent2f36ecfff0fd6f4d5bd83ba61fc1685c4844dd04 (diff)
Rollup merge of #35326 - circuitfox:E0119-update-error-format, r=jonathandturner
E0119 update error format

Part of #35233, fixes #35252

r? @jonathandturner
-rw-r--r--src/librustc_typeck/coherence/overlap.rs12
-rw-r--r--src/test/compile-fail/E0119.rs3
-rw-r--r--src/test/compile-fail/issue-28568.rs3
3 files changed, 13 insertions, 5 deletions
diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs
index dcaa5cfb20a..54bd141304d 100644
--- a/src/librustc_typeck/coherence/overlap.rs
+++ b/src/librustc_typeck/coherence/overlap.rs
@@ -141,12 +141,18 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
                         self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119,
                         "conflicting implementations of trait `{}`{}:",
                         overlap.trait_desc,
-                        overlap.self_desc.map_or(String::new(),
-                                                 |ty| format!(" for type `{}`", ty)));
+                        overlap.self_desc.clone().map_or(String::new(),
+                                                         |ty| format!(" for type `{}`", ty)));
 
                     match self.tcx.span_of_impl(overlap.with_impl) {
                         Ok(span) => {
-                            err.span_note(span, "conflicting implementation is here:");
+                            err.span_label(span,
+                                           &format!("first implementation here"));
+                            err.span_label(self.tcx.span_of_impl(impl_def_id).unwrap(),
+                                           &format!("conflicting implementation{}",
+                                                    overlap.self_desc
+                                                        .map_or(String::new(),
+                                                                |ty| format!(" for `{}`", ty))));
                         }
                         Err(cname) => {
                             err.note(&format!("conflicting implementation in crate `{}`",
diff --git a/src/test/compile-fail/E0119.rs b/src/test/compile-fail/E0119.rs
index 9528631b304..56820bcd184 100644
--- a/src/test/compile-fail/E0119.rs
+++ b/src/test/compile-fail/E0119.rs
@@ -12,7 +12,7 @@ trait MyTrait {
     fn get(&self) -> usize;
 }
 
-impl<T> MyTrait for T {
+impl<T> MyTrait for T { //~ NOTE first implementation here
     fn get(&self) -> usize { 0 }
 }
 
@@ -21,6 +21,7 @@ struct Foo {
 }
 
 impl MyTrait for Foo { //~ ERROR E0119
+                       //~| NOTE conflicting implementation for `Foo`
     fn get(&self) -> usize { self.value }
 }
 
diff --git a/src/test/compile-fail/issue-28568.rs b/src/test/compile-fail/issue-28568.rs
index 7c051784f61..f03daafc637 100644
--- a/src/test/compile-fail/issue-28568.rs
+++ b/src/test/compile-fail/issue-28568.rs
@@ -11,12 +11,13 @@
 struct MyStruct;
 
 impl Drop for MyStruct {
-//~^ NOTE conflicting implementation is here
+//~^ NOTE first implementation here
     fn drop(&mut self) { }
 }
 
 impl Drop for MyStruct {
 //~^ ERROR conflicting implementations of trait
+//~| NOTE conflicting implementation for `MyStruct`
     fn drop(&mut self) { }
 }