]> git.lizzy.rs Git - rust.git/commitdiff
Update E0520 to new error format
authorMohit Agarwal <mohit@sdf.org>
Tue, 30 Aug 2016 04:51:27 +0000 (10:21 +0530)
committerMohit Agarwal <mohit@sdf.org>
Tue, 30 Aug 2016 14:50:01 +0000 (20:20 +0530)
Fixes #36112.
Part of #35233.

r? @jonathandturner

src/librustc_typeck/check/mod.rs
src/test/compile-fail/E0520.rs

index 8f2dc42726696e462759f6a1ec84ebab91039df8..e73c3e2de5320e16cfff17ba5aa348f439412681 100644 (file)
@@ -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));
index bb52843ee78351e8db9045af4b77515d3cd157b7..0bb8faea62e1ea9267f1c64f44b207eb1a65cf9b 100644 (file)
@@ -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() {