Auto merge of #69649 - estebank:negative-impl-span, r=Centril
Tweak output for invalid negative impl errors Follow up to #69722. Tweak negative impl errors emitted in the HIR: ``` error[E0192]: invalid negative impl --> $DIR/E0192.rs:9:6 | LL | impl !Trait for Foo { } | ^^^^^^ | = note: negative impls are only allowed for auto traits, like `Send` and `Sync` ```
This commit is contained in:
commit
8549cfed4b
14 changed files with 95 additions and 50 deletions
|
|
@ -1,8 +1,10 @@
|
|||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
--> $DIR/E0192.rs:9:1
|
||||
error[E0192]: invalid negative impl
|
||||
--> $DIR/E0192.rs:9:6
|
||||
|
|
||||
LL | impl !Trait for Foo { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: negative impls are only allowed for auto traits, like `Send` and `Sync`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be defau
|
|||
default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default
|
||||
|
||||
trait Tr {}
|
||||
default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits
|
||||
default impl !Tr for S {} //~ ERROR invalid negative impl
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -9,22 +9,28 @@ LL | default impl S {}
|
|||
= note: only trait implementations may be annotated with `default`
|
||||
|
||||
error: impls of auto traits cannot be default
|
||||
--> $DIR/validation.rs:9:1
|
||||
--> $DIR/validation.rs:9:21
|
||||
|
|
||||
LL | default unsafe impl Send for S {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------- ^^^^ auto trait
|
||||
| |
|
||||
| default because of this
|
||||
|
||||
error: impls of auto traits cannot be default
|
||||
--> $DIR/validation.rs:10:1
|
||||
--> $DIR/validation.rs:10:15
|
||||
|
|
||||
LL | default impl !Send for Z {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------- ^^^^ auto trait
|
||||
| |
|
||||
| default because of this
|
||||
|
||||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
--> $DIR/validation.rs:13:1
|
||||
error[E0192]: invalid negative impl
|
||||
--> $DIR/validation.rs:13:14
|
||||
|
|
||||
LL | default impl !Tr for S {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^
|
||||
|
|
||||
= note: negative impls are only allowed for auto traits, like `Send` and `Sync`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait TestTrait {}
|
|||
unsafe impl !Send for TestType {}
|
||||
//~^ ERROR negative impls cannot be unsafe
|
||||
impl !TestTrait for TestType {}
|
||||
//~^ ERROR negative impls are only allowed for auto traits
|
||||
//~^ ERROR invalid negative impl
|
||||
|
||||
struct TestType2<T>(T);
|
||||
|
||||
|
|
@ -22,6 +22,6 @@ impl<T> !TestType2<T> {}
|
|||
unsafe impl<T> !Send for TestType2<T> {}
|
||||
//~^ ERROR negative impls cannot be unsafe
|
||||
impl<T> !TestTrait for TestType2<T> {}
|
||||
//~^ ERROR negative impls are only allowed for auto traits
|
||||
//~^ ERROR invalid negative impl
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -32,17 +32,21 @@ LL | unsafe impl<T> !Send for TestType2<T> {}
|
|||
| | negative because of this
|
||||
| unsafe because of this
|
||||
|
||||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
--> $DIR/syntax-trait-polarity.rs:14:1
|
||||
error[E0192]: invalid negative impl
|
||||
--> $DIR/syntax-trait-polarity.rs:14:6
|
||||
|
|
||||
LL | impl !TestTrait for TestType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: negative impls are only allowed for auto traits, like `Send` and `Sync`
|
||||
|
||||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
--> $DIR/syntax-trait-polarity.rs:24:1
|
||||
error[E0192]: invalid negative impl
|
||||
--> $DIR/syntax-trait-polarity.rs:24:9
|
||||
|
|
||||
LL | impl<T> !TestTrait for TestType2<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: negative impls are only allowed for auto traits, like `Send` and `Sync`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ trait TestTrait {
|
|||
}
|
||||
|
||||
impl !TestTrait for TestType {}
|
||||
//~^ ERROR negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
//~^ ERROR invalid negative impl
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||
--> $DIR/typeck-negative-impls-builtin.rs:9:1
|
||||
error[E0192]: invalid negative impl
|
||||
--> $DIR/typeck-negative-impls-builtin.rs:9:6
|
||||
|
|
||||
LL | impl !TestTrait for TestType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: negative impls are only allowed for auto traits, like `Send` and `Sync`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue