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:
bors 2020-03-23 12:40:36 +00:00
commit 8549cfed4b
14 changed files with 95 additions and 50 deletions

View file

@ -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

View file

@ -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() {}

View file

@ -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

View file

@ -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() {}

View file

@ -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

View file

@ -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() {}

View file

@ -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