]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0229.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0229.md
CommitLineData
60c5eb7d 1An associated type binding was done outside of the type parameter declaration
dfeec247
XL
2and `where` clause.
3
4Erroneous code example:
60c5eb7d
XL
5
6```compile_fail,E0229
7pub trait Foo {
8 type A;
9 fn boo(&self) -> <Self as Foo>::A;
10}
11
12struct Bar;
13
14impl Foo for isize {
15 type A = usize;
16 fn boo(&self) -> usize { 42 }
17}
18
19fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
20// error: associated type bindings are not allowed here
21```
22
23To solve this error, please move the type bindings in the type parameter
24declaration:
25
26```
27# struct Bar;
28# trait Foo { type A; }
29fn baz<I: Foo<A=Bar>>(x: &<I as Foo>::A) {} // ok!
30```
31
32Or in the `where` clause:
33
34```
35# struct Bar;
36# trait Foo { type A; }
37fn baz<I>(x: &<I as Foo>::A) where I: Foo<A=Bar> {}
38```