]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0774.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0774.md
1 `derive` was applied on something which is not a struct, a union or an enum.
2
3 Erroneous code example:
4
5 ```compile_fail,E0774
6 trait Foo {
7     #[derive(Clone)] // error!
8     type Bar;
9 }
10 ```
11
12 As said above, the `derive` attribute is only allowed on structs, unions or
13 enums:
14
15 ```
16 #[derive(Clone)] // ok!
17 struct Bar {
18     field: u32,
19 }
20 ```
21
22 You can find more information about `derive` in the [Rust Book].
23
24 [Rust Book]: https://doc.rust-lang.org/book/appendix-03-derivable-traits.html