File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 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+
113Safe traits should not have unsafe implementations, therefore marking an
214implementation 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+ ```
618struct Foo;
719
820trait 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```
You can’t perform that action at this time.
0 commit comments