forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#68317 - GuillaumeGomez:clean-up-e0199, r=Dy…
…lan-DPC Clean up E0199 explanation r? @Dylan-DPC
- Loading branch information
Showing
1 changed file
with
15 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! | ||
``` |