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
a1a0aea
commit 6f1bdb4
Showing
1 changed file
with
12 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,13 +1,20 @@ | ||
An inherent implementation was marked unsafe. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0197 | ||
struct Foo; | ||
unsafe impl Foo { } // error! | ||
``` | ||
|
||
Inherent implementations (one that do not implement a trait but provide | ||
methods associated with a type) are always safe because they are not | ||
implementing an unsafe trait. Removing the `unsafe` keyword from the inherent | ||
implementation will resolve this error. | ||
|
||
```compile_fail,E0197 | ||
``` | ||
struct Foo; | ||
// this will cause this error | ||
unsafe impl Foo { } | ||
// converting it to this will fix it | ||
impl Foo { } | ||
impl Foo { } // ok! | ||
``` |