Shrink E0205 span label to the trait being implemented

This commit is contained in:
Keith Yeung 2016-08-07 21:34:51 -07:00
parent 1744c46e47
commit c6e17ec276
2 changed files with 14 additions and 9 deletions

View File

@ -321,13 +321,18 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
}
Err(CopyImplementationError::InfrigingVariant(name)) => {
struct_span_err!(tcx.sess, span, E0205,
"the trait `Copy` may not be \
implemented for this type")
.span_label(span, &format!("variant \
`{}` does not implement `Copy`",
name))
.emit()
let item = tcx.map.expect_item(impl_node_id);
let span = if let ItemImpl(_, _, _, Some(ref tr), _, _) = item.node {
tr.path.span
} else {
span
};
struct_span_err!(tcx.sess, span, E0205,
"the trait `Copy` may not be implemented for this type")
.span_label(span, &format!("variant `{}` does not implement `Copy`",
name))
.emit()
}
Err(CopyImplementationError::NotAnAdt) => {
span_err!(tcx.sess, span, E0206,

View File

@ -14,11 +14,11 @@ enum Foo {
}
impl Copy for Foo { }
//~^ ERROR E0205
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE variant `Bar` does not implement `Copy`
#[derive(Copy)]
//~^ ERROR E0205
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE variant `Bar` does not implement `Copy`
//~| NOTE in this expansion of #[derive(Copy)]
enum Foo2<'a> {