]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0198.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0198.md
1 A negative implementation was marked as unsafe.
2
3 Erroneous code example:
4
5 ```compile_fail,E0198
6 struct Foo;
7
8 unsafe impl !Clone for Foo { } // error!
9 ```
10
11 A negative implementation is one that excludes a type from implementing a
12 particular trait. Not being able to use a trait is always a safe operation,
13 so negative implementations are always safe and never need to be marked as
14 unsafe.
15
16 This will compile:
17
18 ```ignore (ignore auto_trait future compatibility warning)
19 #![feature(auto_traits)]
20
21 struct Foo;
22
23 auto trait Enterprise {}
24
25 impl !Enterprise for Foo { }
26 ```
27
28 Please note that negative impls are only allowed for auto traits.