1
Fork 0

update error messages and explicitly mention them in tests

This commit is contained in:
lcnr 2022-05-05 14:29:24 +02:00
parent ba0ecbdcd4
commit 321162b259
5 changed files with 54 additions and 34 deletions

View file

@ -149,7 +149,7 @@ impl<'tcx> InherentCollect<'tcx> {
self.tcx.sess,
item.span,
E0390,
"cannot define inherent `impl` for a type outside of crate where the type is defined",
"cannot define inherent `impl` for a type outside of the crate where the type is defined",
)
.help(INTO_DEFINING_CRATE)
.span_help(item.span, ADD_ATTR_TO_TY)
@ -166,7 +166,7 @@ impl<'tcx> InherentCollect<'tcx> {
self.tcx.sess,
item.span,
E0390,
"cannot define inherent `impl` for a type outside of crate where the type is defined",
"cannot define inherent `impl` for a type outside of the crate where the type is defined",
)
.help(INTO_DEFINING_CRATE)
.span_help(impl_item.span, ADD_ATTR)

View file

@ -2,31 +2,37 @@
#![feature(rustc_attrs)]
extern crate extern_crate;
impl extern_crate::StructWithAttr { //~ ERROR
impl extern_crate::StructWithAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
fn foo() {}
}
impl extern_crate::StructWithAttr {
#[rustc_allow_incoherent_impl]
fn bar() {}
}
impl extern_crate::StructNoAttr { //~ ERROR
impl extern_crate::StructNoAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
fn foo() {}
}
impl extern_crate::StructNoAttr { //~ ERROR
impl extern_crate::StructNoAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
#[rustc_allow_incoherent_impl]
fn bar() {}
}
impl extern_crate::EnumWithAttr { //~ ERROR
impl extern_crate::EnumWithAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
fn foo() {}
}
impl extern_crate::EnumWithAttr {
#[rustc_allow_incoherent_impl]
fn bar() {}
}
impl extern_crate::EnumNoAttr { //~ ERROR
impl extern_crate::EnumNoAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
fn foo() {}
}
impl extern_crate::EnumNoAttr { //~ ERROR
impl extern_crate::EnumNoAttr {
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
#[rustc_allow_incoherent_impl]
fn bar() {}
}

View file

@ -1,39 +1,43 @@
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:5:1
|
LL | / impl extern_crate::StructWithAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:6:5
--> $DIR/needs-has-incoherent-impls.rs:7:5
|
LL | fn foo() {}
| ^^^^^^^^^^^
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:12:1
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:13:1
|
LL | / impl extern_crate::StructNoAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:12:1
--> $DIR/needs-has-incoherent-impls.rs:13:1
|
LL | / impl extern_crate::StructNoAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:15:1
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:17:1
|
LL | / impl extern_crate::StructNoAttr {
LL | |
LL | | #[rustc_allow_incoherent_impl]
LL | | fn bar() {}
LL | | }
@ -41,50 +45,55 @@ LL | | }
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:15:1
--> $DIR/needs-has-incoherent-impls.rs:17:1
|
LL | / impl extern_crate::StructNoAttr {
LL | |
LL | | #[rustc_allow_incoherent_impl]
LL | | fn bar() {}
LL | | }
| |_^
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:19:1
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:22:1
|
LL | / impl extern_crate::EnumWithAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:20:5
--> $DIR/needs-has-incoherent-impls.rs:24:5
|
LL | fn foo() {}
| ^^^^^^^^^^^
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:26:1
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:30:1
|
LL | / impl extern_crate::EnumNoAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:26:1
--> $DIR/needs-has-incoherent-impls.rs:30:1
|
LL | / impl extern_crate::EnumNoAttr {
LL | |
LL | | fn foo() {}
LL | | }
| |_^
error[E0390]: cannot define inherent `impl` for a type outside of crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:29:1
error[E0390]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/needs-has-incoherent-impls.rs:34:1
|
LL | / impl extern_crate::EnumNoAttr {
LL | |
LL | | #[rustc_allow_incoherent_impl]
LL | | fn bar() {}
LL | | }
@ -92,9 +101,10 @@ LL | | }
|
= help: consider moving this inherent impl into the crate defining the type if possible
help: alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items
--> $DIR/needs-has-incoherent-impls.rs:29:1
--> $DIR/needs-has-incoherent-impls.rs:34:1
|
LL | / impl extern_crate::EnumNoAttr {
LL | |
LL | | #[rustc_allow_incoherent_impl]
LL | | fn bar() {}
LL | | }

View file

@ -1,14 +1,18 @@
// aux-build:extern-crate.rs
extern crate extern_crate;
impl extern_crate::StructWithAttr {} //~ ERROR
impl extern_crate::StructWithAttr {}
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
impl extern_crate::StructNoAttr {} //~ ERROR
impl extern_crate::StructNoAttr {}
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
impl extern_crate::EnumWithAttr {} //~ ERROR
impl extern_crate::EnumWithAttr {}
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
impl extern_crate::EnumNoAttr {} //~ ERROR
impl extern_crate::EnumNoAttr {}
//~^ ERROR cannot define inherent `impl` for a type outside of the crate
impl f32 {} //~ ERROR
impl f32 {} //~ ERROR cannot define inherent `impl` for primitive types
fn main() {}

View file

@ -7,7 +7,7 @@ LL | impl extern_crate::StructWithAttr {}
= note: define and implement a trait or new type instead
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/no-attr-empty-impl.rs:6:1
--> $DIR/no-attr-empty-impl.rs:7:1
|
LL | impl extern_crate::StructNoAttr {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate.
@ -15,7 +15,7 @@ LL | impl extern_crate::StructNoAttr {}
= note: define and implement a trait or new type instead
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/no-attr-empty-impl.rs:8:1
--> $DIR/no-attr-empty-impl.rs:10:1
|
LL | impl extern_crate::EnumWithAttr {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate.
@ -23,7 +23,7 @@ LL | impl extern_crate::EnumWithAttr {}
= note: define and implement a trait or new type instead
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> $DIR/no-attr-empty-impl.rs:10:1
--> $DIR/no-attr-empty-impl.rs:13:1
|
LL | impl extern_crate::EnumNoAttr {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate.
@ -31,7 +31,7 @@ LL | impl extern_crate::EnumNoAttr {}
= note: define and implement a trait or new type instead
error[E0390]: cannot define inherent `impl` for primitive types
--> $DIR/no-attr-empty-impl.rs:12:6
--> $DIR/no-attr-empty-impl.rs:16:6
|
LL | impl f32 {}
| ^^^