]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0199.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0199.md
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
13 Safe traits should not have unsafe implementations, therefore marking an
14 implementation for a safe trait unsafe will cause a compiler error. Removing
15 the unsafe marker on the trait noted in the error will resolve this problem:
16
17 ```
18 struct Foo;
19
20 trait Bar { }
21
22 impl Bar for Foo { } // ok!
23 ```