Skip to content

Commit

Permalink
Rollup merge of rust-lang#35484 - KiChjang:e0205-bonus, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Shrink E0205 span label to the trait being implemented

Part of rust-lang#35233.
Extension of rust-lang#35468.
Closes rust-lang#35382.

r? @GuillaumeGomez
  • Loading branch information
Jonathan Turner committed Aug 8, 2016
2 parents 8a7edc0 + c6e17ec commit a72891e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions src/librustc_typeck/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
let item = tcx.map.expect_item(impl_node_id);
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/E0205.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit a72891e

Please sign in to comment.