File tree 1 file changed +15
-6
lines changed
src/librustc_error_codes/error_codes
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
+
1
13
Safe traits should not have unsafe implementations, therefore marking an
2
14
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:
4
16
5
- ``` compile_fail,E0199
17
+ ```
6
18
struct Foo;
7
19
8
20
trait Bar { }
9
21
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!
14
23
```
You can’t perform that action at this time.
0 commit comments