Skip to content

#36553 specialisation error 520 is misleading #36652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,15 @@ fn report_forbidden_specialization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mut err = struct_span_err!(
tcx.sess, impl_item.span, E0520,
"`{}` specializes an item from a parent `impl`, but \
neither that item nor the `impl` are marked `default`",
that item is not 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_label(span, &"parent `impl` is here");
err.note(&format!("to specialize, either the parent `impl` or `{}` \
err.note(&format!("to specialize, `{}` \
in the parent `impl` must be marked `default`",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this string could all fit on one line now.

impl_item.name));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0520.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl SpaceLlama for i32 {
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`
//~| NOTE `fly` in the parent `impl` must be marked `default`
}

fn main() {
Expand Down