Auto merge of #35402 - KiChjang:e0206-new-msg, r=GuillaumeGomez
Update E0206 message to new format Part of #35233. Fixes #35301. r? @GuillaumeGomez
This commit is contained in:
commit
6153bbbe38
@ -330,10 +330,17 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
|
||||
.emit()
|
||||
}
|
||||
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,
|
||||
|
@ -10,13 +10,19 @@
|
||||
|
||||
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 only traits defined in the current crate can be implemented for arbitrary types
|
||||
//~| NOTE impl doesn't use types inside crate
|
||||
//~| NOTE the impl does not reference any types defined in this crate
|
||||
|
||||
#[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() {
|
||||
}
|
||||
|
@ -27,23 +27,34 @@ 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 E0117
|
||||
//~^ ERROR the trait `Copy` may not be implemented for this type
|
||||
//~| NOTE type is not a structure or enumeration
|
||||
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
|
||||
//~| NOTE impl doesn't use types inside crate
|
||||
//~| NOTE the impl does not reference any types defined in this crate
|
||||
|
||||
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 E0117
|
||||
//~^ ERROR the trait `Copy` may not be implemented for this type
|
||||
//~| NOTE type is not a structure or enumeration
|
||||
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
|
||||
//~| NOTE impl doesn't use types inside crate
|
||||
//~| NOTE the impl does not reference any types defined in this crate
|
||||
|
||||
impl Copy for &'static [NotSync] {}
|
||||
//~^ ERROR E0206
|
||||
//~| ERROR E0117
|
||||
//~^ ERROR the trait `Copy` may not be implemented for this type
|
||||
//~| NOTE type is not a structure or enumeration
|
||||
//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
|
||||
//~| NOTE impl doesn't use types inside crate
|
||||
//~| NOTE the impl does not reference any types defined in this crate
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user