]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0741.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.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(adt_const_params)]
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(adt_const_params)]
20
21 #[derive(PartialEq, Eq)] // We derive both traits here.
22 struct A;
23
24 struct B<const X: A>; // ok!
25 ```