]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_error_codes/src/error_codes/E0321.md
New upstream version 1.68.2+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0321.md
CommitLineData
60c5eb7d 1A cross-crate opt-out trait was implemented on something which wasn't a struct
74b04a01
XL
2or enum type.
3
4Erroneous code example:
60c5eb7d
XL
5
6```compile_fail,E0321
fc512014 7#![feature(auto_traits)]
60c5eb7d
XL
8
9struct Foo;
10
11impl !Sync for Foo {}
12
13unsafe impl Send for &'static Foo {}
14// error: cross-crate traits with a default impl, like `core::marker::Send`,
15// can only be implemented for a struct/enum type, not
16// `&'static Foo`
17```
18
19Only structs and enums are permitted to impl Send, Sync, and other opt-out
20trait, and the struct or enum must be local to the current crate. So, for
21example, `unsafe impl Send for Rc<Foo>` is not allowed.