Skip to content

Commit

Permalink
Clean up E0199 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 17, 2020
1 parent bf84eb5 commit e8a4b93
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 e8a4b93

Please sign in to comment.