Skip to content

Commit 6f1bdb4

Browse files
clean up E0197 explanation
1 parent a1a0aea commit 6f1bdb4

File tree

1 file changed

+12
-5
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+12
-5
lines changed
+12-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
An inherent implementation was marked unsafe.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0197
6+
struct Foo;
7+
8+
unsafe impl Foo { } // error!
9+
```
10+
111
Inherent implementations (one that do not implement a trait but provide
212
methods associated with a type) are always safe because they are not
313
implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
414
implementation will resolve this error.
515

6-
```compile_fail,E0197
16+
```
717
struct Foo;
818
9-
// this will cause this error
10-
unsafe impl Foo { }
11-
// converting it to this will fix it
12-
impl Foo { }
19+
impl Foo { } // ok!
1320
```

0 commit comments

Comments
 (0)