Skip to content

Commit

Permalink
Rollup merge of rust-lang#75360 - pickfire:patch-4, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Add sample fix for E0749

Even though the description is clear but the solution may not be as straightforward.
Adding a suggested fix from documentation side.

r? @GuillaumeGomez

However, this suggestion should be shown in rustc itself for easy fix, the documentation should also reflect on the changes in rustc. Currently,
```
error[E0749]: negative impls cannot have any items
 --> test.rs:6:5
  |
6 |     type Foo = i32; // error!
  |     ^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0749`.
```
rustc should tell the user to remove it.
  • Loading branch information
JohnTitor authored Aug 11, 2020
2 parents ca462d3 + a7f61bf commit 5320028
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/librustc_error_codes/error_codes/E0749.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ trait MyTrait {
impl !MyTrait for u32 {
type Foo = i32; // error!
}
# fn main() {}
```

Negative impls are not allowed to have any items. Negative impls declare that a
trait is **not** implemented (and never will be) and hence there is no need to
specify the values for trait methods or other items.

One way to fix this is to remove the items in negative impls:

```
# #![feature(negative_impls)]
trait MyTrait {
type Foo;
}
impl !MyTrait for u32 {}
```

0 comments on commit 5320028

Please sign in to comment.