Skip to content

Commit

Permalink
Rollup merge of rust-lang#68317 - GuillaumeGomez:clean-up-e0199, r=Dy…
Browse files Browse the repository at this point in the history
…lan-DPC

Clean up E0199 explanation

r? @Dylan-DPC
  • Loading branch information
tmandry authored Jan 18, 2020
2 parents f44a12e + e8a4b93 commit af17550
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/librustc_error_codes/error_codes/E0199.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
A trait implementation was marked as unsafe while the trait is safe.

Erroneous code example:

```compile_fail,E0199
struct Foo;
trait Bar { }
unsafe impl Bar for Foo { } // error!
```

Safe traits should not have unsafe implementations, therefore marking an
implementation for a safe trait unsafe will cause a compiler error. Removing
the unsafe marker on the trait noted in the error will resolve this problem.
the unsafe marker on the trait noted in the error will resolve this problem:

```compile_fail,E0199
```
struct Foo;
trait Bar { }
// this won't compile because Bar is safe
unsafe impl Bar for Foo { }
// this will compile
impl Bar for Foo { }
impl Bar for Foo { } // ok!
```

0 comments on commit af17550

Please sign in to comment.