]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #35314 - yossi-k:issue/35277, r=jonathandturner
authorJonathan Turner <jonathandturner@users.noreply.github.com>
Sun, 7 Aug 2016 16:59:40 +0000 (09:59 -0700)
committerGitHub <noreply@github.com>
Sun, 7 Aug 2016 16:59:40 +0000 (09:59 -0700)
Update E0185 and E0186 to new format

Part of #35233.
Fixes #35277.
Fixes #35276.
r? @jonathandturner

src/librustc_typeck/check/compare_method.rs
src/test/compile-fail/E0185.rs
src/test/compile-fail/E0186.rs

index 9844377d0bd32f5241c1e0cb948f48597c1d5673..b971ae02cd0bd27a87905137df7540a80142257b 100644 (file)
@@ -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;
         }
         _ => {
index 0e33687a84dfb6857fae8f563c874600bc434f73..be54c3754ea1fe98e7aef7f4aaef686d8282f629 100644 (file)
@@ -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() {
index aa0a38bedcb543e932123f4bb59d0798c6658a19..55a3490cac4a620b9206e243cd81687e084edb8d 100644 (file)
@@ -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() {