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