@@ -161,6 +161,68 @@ it has been disabled for now.
161
161
[iss20126]: https://github.com/rust-lang/rust/issues/20126
162
162
"## ,
163
163
164
+ E0197 : r##"
165
+ Inherent implementations (one that do not implement a trait but provide
166
+ methods associated with a type) are always safe because they are not
167
+ implementing an unsafe trait. Removing the unsafe keyword from the inherent
168
+ implementation will resolve this error.
169
+
170
+ struct Foo;
171
+
172
+ // this will cause this error
173
+ unsafe impl Foo { }
174
+ // converting it to this will fix it
175
+ impl Foo { }
176
+
177
+ "## ,
178
+
179
+ E0198 : r##"
180
+ A negative implementation is one that excludes a type from implementing a
181
+ particular trait. Not being able to use a trait is always a safe operation,
182
+ so negative implementations are always safe and never need to be marked as
183
+ unsafe.
184
+
185
+ struct Foo;
186
+
187
+ // unsafe is unnecessary
188
+ unsafe impl !Clone for Foo { }
189
+ // this will compile
190
+ impl !Clone for Foo { }
191
+
192
+ "## ,
193
+
194
+ E0199 : r##"
195
+ Safe traits should not have unsafe implementations, therefore marking an
196
+ implementation for a safe trait unsafe will cause a compiler error. Removing the
197
+ unsafe marker on the trait noted in the error will resolve this problem.
198
+
199
+ struct Foo;
200
+
201
+ trait Bar { }
202
+
203
+ // this won't compile because Bar is safe
204
+ unsafe impl Bar for Foo { }
205
+ // this will compile
206
+ impl Bar for Foo { }
207
+
208
+ "## ,
209
+
210
+ E0200 : r##"
211
+ Unsafe traits must have unsafe implementations. This error occurs when an
212
+ implementation for an unsafe trait isn't marked as unsafe. This may be resolved
213
+ by marking the unsafe implementation as unsafe.
214
+
215
+ struct Foo;
216
+
217
+ unsafe trait Bar { }
218
+
219
+ // this won't compile because Bar is unsafe and impl isn't unsafe
220
+ impl Bar for Foo { }
221
+ // this will compile
222
+ unsafe impl Bar for Foo { }
223
+
224
+ "## ,
225
+
164
226
E0204 : r##"
165
227
An attempt to implement the `Copy` trait for a struct failed because one of the
166
228
fields does not implement `Copy`. To fix this, you must implement `Copy` for the
@@ -386,10 +448,6 @@ register_diagnostics! {
386
448
E0194 ,
387
449
E0195 , // lifetime parameters or bounds on method do not match the trait declaration
388
450
E0196 , // cannot determine a type for this closure
389
- E0197 , // inherent impls cannot be declared as unsafe
390
- E0198 , // negative implementations are not unsafe
391
- E0199 , // implementing trait is not unsafe
392
- E0200 , // trait requires an `unsafe impl` declaration
393
451
E0201 , // duplicate method in trait impl
394
452
E0202 , // associated items are not allowed in inherent impls
395
453
E0203 , // type parameter has more than one relaxed default bound,
0 commit comments