about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2016-08-31 06:29:10 -0700
committerGitHub <noreply@github.com>2016-08-31 06:29:10 -0700
commitf3ce9fd5a72391fc239b9d2956a5d094ba056a71 (patch)
tree31502dde962427bfc5ac52c60769697243d87549
parent422305af7b604d7825a20e910bf9f53e7914a0ad (diff)
parent77cd09a88cd21f22865287025dafc1252856c5d9 (diff)
Rollup merge of #36135 - 0xmohit:pr/error-code-E0520, r=jonathandturner
Update E0520 to new error format

Fixes #36112.
Part of #35233.

r? @jonathandturner
-rw-r--r--src/librustc_typeck/check/mod.rs12
-rw-r--r--src/test/compile-fail/E0520.rs6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 70e90980e1d..a7ea8bd7959 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -903,14 +903,18 @@ fn report_forbidden_specialization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 {
     let mut err = struct_span_err!(
         tcx.sess, impl_item.span, E0520,
-        "item `{}` is provided by an `impl` that specializes \
-         another, but the item in the parent `impl` is not \
-         marked `default` and so it cannot be specialized.",
+        "`{}` specializes an item from a parent `impl`, but \
+         neither that item nor the `impl` are marked `default`",
         impl_item.name);
+    err.span_label(impl_item.span, &format!("cannot specialize default item `{}`",
+                                            impl_item.name));
 
     match tcx.span_of_impl(parent_impl) {
         Ok(span) => {
-            err.span_note(span, "parent implementation is here:");
+            err.span_label(span, &"parent `impl` is here");
+            err.note(&format!("to specialize, either the parent `impl` or `{}` \
+                               in the parent `impl` must be marked `default`",
+                              impl_item.name));
         }
         Err(cname) => {
             err.note(&format!("parent implementation is in crate `{}`", cname));
diff --git a/src/test/compile-fail/E0520.rs b/src/test/compile-fail/E0520.rs
index bb52843ee78..0bb8faea62e 100644
--- a/src/test/compile-fail/E0520.rs
+++ b/src/test/compile-fail/E0520.rs
@@ -19,11 +19,15 @@ impl<T> SpaceLlama for T {
 }
 
 impl<T: Clone> SpaceLlama for T {
+//~^ NOTE parent `impl` is here
     fn fly(&self) {}
 }
 
 impl SpaceLlama for i32 {
-    default fn fly(&self) {} //~ ERROR E0520
+    default fn fly(&self) {}
+    //~^ ERROR E0520
+    //~| NOTE cannot specialize default item `fly`
+    //~| NOTE either the parent `impl` or `fly` in the parent `impl` must be marked `default`
 }
 
 fn main() {