]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0741.md
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0741.md
1 A non-structural-match type was used as the type of a const generic parameter.
2
3 Erroneous code example:
4
5 ```compile_fail,E0741
6 #![feature(const_generics)]
7
8 struct A;
9
10 struct B<const X: A>; // error!
11 ```
12
13 Only structural-match types (that is, types that derive `PartialEq` and `Eq`)
14 may be used as the types of const generic parameters.
15
16 To fix the previous code example, we derive `PartialEq` and `Eq`:
17
18 ```
19 #![feature(const_generics)]
20
21 #[derive(PartialEq, Eq)] // We derive both traits here.
22 struct A;
23
24 struct B<const X: A>; // ok!
25 ```