-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf84eb5
commit 9746b05
Showing
1 changed file
with
14 additions
and
5 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 @@ | ||
An unsafe trait was implemented without an unsafe implementation. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0200 | ||
struct Foo; | ||
unsafe trait Bar { } | ||
impl Bar for Foo { } // error! | ||
``` | ||
|
||
Unsafe traits must have unsafe implementations. This error occurs when an | ||
implementation for an unsafe trait isn't marked as unsafe. This may be resolved | ||
by marking the unsafe implementation as unsafe. | ||
|
||
```compile_fail,E0200 | ||
``` | ||
struct Foo; | ||
unsafe trait Bar { } | ||
// this won't compile because Bar is unsafe and impl isn't unsafe | ||
impl Bar for Foo { } | ||
// this will compile | ||
unsafe impl Bar for Foo { } | ||
unsafe impl Bar for Foo { } // ok! | ||
``` |