Skip to content

Commit

Permalink
clean up E0197 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 16, 2020
1 parent a1a0aea commit 6f1bdb4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/librustc_error_codes/error_codes/E0197.md
@@ -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!
```

0 comments on commit 6f1bdb4

Please sign in to comment.