Skip to content

Commit b7af138

Browse files
authored
Rollup merge of #68317 - GuillaumeGomez:clean-up-e0199, r=Dylan-DPC
Clean up E0199 explanation r? @Dylan-DPC
2 parents 0f849b9 + e8a4b93 commit b7af138

File tree

1 file changed

+15
-6
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+15
-6
lines changed
+15-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
A trait implementation was marked as unsafe while the trait is safe.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0199
6+
struct Foo;
7+
8+
trait Bar { }
9+
10+
unsafe impl Bar for Foo { } // error!
11+
```
12+
113
Safe traits should not have unsafe implementations, therefore marking an
214
implementation for a safe trait unsafe will cause a compiler error. Removing
3-
the unsafe marker on the trait noted in the error will resolve this problem.
15+
the unsafe marker on the trait noted in the error will resolve this problem:
416

5-
```compile_fail,E0199
17+
```
618
struct Foo;
719
820
trait Bar { }
921
10-
// this won't compile because Bar is safe
11-
unsafe impl Bar for Foo { }
12-
// this will compile
13-
impl Bar for Foo { }
22+
impl Bar for Foo { } // ok!
1423
```

0 commit comments

Comments
 (0)