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