File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -2787,23 +2787,42 @@ You used an associated type which isn't defined in the trait.
27872787Erroneous code example:
27882788
27892789```compile_fail
2790- trait Trait {
2790+ trait T1 {
27912791 type Bar;
27922792}
27932793
2794- type Foo = Trait<F=i32>; // error: associated type `F` not found for
2795- // `Trait`
2794+ type Foo = T1<F=i32>; // error: associated type `F` not found for `T1`
2795+
2796+ // or:
2797+
2798+ trait T2 {
2799+ type Bar;
2800+
2801+ // error: Baz is used but not declared
2802+ fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
2803+ }
27962804```
27972805
2798- Please verify you used the right trait or you didn't misspell the
2806+ Make sure that you have defined the associated type in the trait body.
2807+ Also, verify that you used the right trait or you didn't misspell the
27992808associated type name. Example:
28002809
28012810```
2802- trait Trait {
2811+ trait T1 {
28032812 type Bar;
28042813}
28052814
2806- type Foo = Trait<Bar=i32>; // ok!
2815+ type Foo = T1<Bar=i32>; // ok!
2816+
2817+ // or:
2818+
2819+ trait T2 {
2820+ type Bar;
2821+ type Baz; // we declare `Baz` in our trait.
2822+
2823+ // and now we can use it here:
2824+ fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
2825+ }
28072826```
28082827"## ,
28092828
You can’t perform that action at this time.
0 commit comments