Skip to content

Commit

Permalink
Rollup merge of rust-lang#35402 - KiChjang:e0206-new-msg, r=Guillaume…
Browse files Browse the repository at this point in the history
…Gomez

Update E0206 message to new format

Part of rust-lang#35233.
Fixes rust-lang#35301.

r? @GuillaumeGomez
  • Loading branch information
Jonathan Turner authored Aug 6, 2016
2 parents 5e84fc4 + 5bab0e6 commit ae59b96
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
15 changes: 11 additions & 4 deletions src/librustc_typeck/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,17 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
name)
}
Err(CopyImplementationError::NotAnAdt) => {
span_err!(tcx.sess, span, E0206,
"the trait `Copy` may not be implemented \
for this type; type is not a structure or \
enumeration")
let item = tcx.map.expect_item(impl_node_id);
let span = if let ItemImpl(_, _, _, _, ref ty, _) = item.node {
ty.span
} else {
span
};

struct_span_err!(tcx.sess, span, E0206,
"the trait `Copy` may not be implemented for this type")
.span_label(span, &format!("type is not a structure or enumeration"))
.emit();
}
Err(CopyImplementationError::HasDestructor) => {
span_err!(tcx.sess, span, E0184,
Expand Down
10 changes: 7 additions & 3 deletions src/test/compile-fail/E0206.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@

type Foo = i32;

impl Copy for Foo { } //~ ERROR E0206
//~^ ERROR E0117
impl Copy for Foo { }
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

#[derive(Copy, Clone)]
struct Bar;

impl Copy for &'static Bar { } //~ ERROR E0206
impl Copy for &'static Bar { }
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration

fn main() {
}
15 changes: 10 additions & 5 deletions src/test/compile-fail/coherence-impls-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } }
impl Copy for MyType {}

impl Copy for &'static mut MyType {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
impl Clone for MyType { fn clone(&self) -> Self { *self } }

impl Copy for (MyType, MyType) {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

impl Copy for &'static NotSync {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration

impl Copy for [MyType] {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

impl Copy for &'static [NotSync] {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

fn main() {
Expand Down

0 comments on commit ae59b96

Please sign in to comment.