]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0220.md
43e075b522b4e8bca46bea34b162b0ef83178a65
[rust.git] / src / librustc_error_codes / error_codes / E0220.md
1 You used an associated type which isn't defined in the trait.
2 Erroneous code example:
3
4 ```compile_fail,E0220
5 trait T1 {
6     type Bar;
7 }
8
9 type Foo = T1<F=i32>; // error: associated type `F` not found for `T1`
10
11 // or:
12
13 trait T2 {
14     type Bar;
15
16     // error: Baz is used but not declared
17     fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;
18 }
19 ```
20
21 Make sure that you have defined the associated type in the trait body.
22 Also, verify that you used the right trait or you didn't misspell the
23 associated type name. Example:
24
25 ```
26 trait T1 {
27     type Bar;
28 }
29
30 type Foo = T1<Bar=i32>; // ok!
31
32 // or:
33
34 trait T2 {
35     type Bar;
36     type Baz; // we declare `Baz` in our trait.
37
38     // and now we can use it here:
39     fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;
40 }
41 ```