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