]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0321.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0321.md
1 A cross-crate opt-out trait was implemented on something which wasn't a struct
2 or enum type. Erroneous code example:
3
4 ```compile_fail,E0321
5 #![feature(optin_builtin_traits)]
6
7 struct Foo;
8
9 impl !Sync for Foo {}
10
11 unsafe impl Send for &'static Foo {}
12 // error: cross-crate traits with a default impl, like `core::marker::Send`,
13 //        can only be implemented for a struct/enum type, not
14 //        `&'static Foo`
15 ```
16
17 Only structs and enums are permitted to impl Send, Sync, and other opt-out
18 trait, and the struct or enum must be local to the current crate. So, for
19 example, `unsafe impl Send for Rc<Foo>` is not allowed.