about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYossi Konstantinovsky <yossi@nuvo-group.com>2016-08-04 20:56:12 +0300
committerYossi Konstantinovsky <yossi@nuvo-group.com>2016-08-07 17:23:17 +0300
commit64873965faed72fe22ab52147455d8d6c5403bb5 (patch)
treeeb77648eeb8a574c1eb0d9a4fc08bad5d07a14ce
parentea07d52676a68aff3e85599469523a25eeb1afbf (diff)
downloadrust-64873965faed72fe22ab52147455d8d6c5403bb5.tar.gz
rust-64873965faed72fe22ab52147455d8d6c5403bb5.zip
Update E0185 and E0186 to new format
-rw-r--r--src/librustc_typeck/check/compare_method.rs18
-rw-r--r--src/test/compile-fail/E0185.rs3
-rw-r--r--src/test/compile-fail/E0186.rs3
3 files changed, 20 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 9844377d0bd..b971ae02cd0 100644
--- a/src/librustc_typeck/check/compare_method.rs
+++ b/src/librustc_typeck/check/compare_method.rs
@@ -59,19 +59,33 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         (&ty::ExplicitSelfCategory::Static,
          &ty::ExplicitSelfCategory::Static) => {}
         (&ty::ExplicitSelfCategory::Static, _) => {
-            span_err!(tcx.sess, impl_m_span, E0185,
+            let mut err = struct_span_err!(tcx.sess, impl_m_span, E0185,
                 "method `{}` has a `{}` declaration in the impl, \
                         but not in the trait",
                         trait_m.name,
                         impl_m.explicit_self);
+            err.span_label(impl_m_span, &format!("`{}` used in impl",
+                                                 impl_m.explicit_self));
+            if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
+                err.span_label(span, &format!("trait declared without `{}`",
+                                              impl_m.explicit_self));
+            }
+            err.emit();
             return;
         }
         (_, &ty::ExplicitSelfCategory::Static) => {
-            span_err!(tcx.sess, impl_m_span, E0186,
+            let mut err = struct_span_err!(tcx.sess, impl_m_span, E0186,
                 "method `{}` has a `{}` declaration in the trait, \
                         but not in the impl",
                         trait_m.name,
                         trait_m.explicit_self);
+            err.span_label(impl_m_span, &format!("expected `{}` in impl",
+                                                  trait_m.explicit_self));
+            if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
+                err.span_label(span, & format!("`{}` used in trait",
+                                               trait_m.explicit_self));
+            }
+            err.emit();
             return;
         }
         _ => {
diff --git a/src/test/compile-fail/E0185.rs b/src/test/compile-fail/E0185.rs
index 0e33687a84d..be54c3754ea 100644
--- a/src/test/compile-fail/E0185.rs
+++ b/src/test/compile-fail/E0185.rs
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 trait Foo {
-    fn foo();
+    fn foo(); //~ trait declared without `&self`
 }
 
 struct Bar;
 
 impl Foo for Bar {
     fn foo(&self) {} //~ ERROR E0185
+    //~^ `&self` used in impl
 }
 
 fn main() {
diff --git a/src/test/compile-fail/E0186.rs b/src/test/compile-fail/E0186.rs
index aa0a38bedcb..55a3490cac4 100644
--- a/src/test/compile-fail/E0186.rs
+++ b/src/test/compile-fail/E0186.rs
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 trait Foo {
-    fn foo(&self);
+    fn foo(&self); //~ `&self` used in trait
 }
 
 struct Bar;
 
 impl Foo for Bar {
     fn foo() {} //~ ERROR E0186
+    //~^ expected `&self` in impl
 }
 
 fn main() {