]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0128.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0128.md
1 Type parameter defaults can only use parameters that occur before them.
2 Erroneous code example:
3
4 ```compile_fail,E0128
5 struct Foo<T = U, U = ()> {
6 field1: T,
7 field2: U,
8 }
9 // error: type parameters with a default cannot use forward declared
10 // identifiers
11 ```
12
13 Since type parameters are evaluated in-order, you may be able to fix this issue
14 by doing:
15
16 ```
17 struct Foo<U = (), T = U> {
18 field1: T,
19 field2: U,
20 }
21 ```
22
23 Please also verify that this wasn't because of a name-clash and rename the type
24 parameter if so.