File tree 1 file changed +25
-6
lines changed
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.
2787
2787
Erroneous code example:
2788
2788
2789
2789
```compile_fail
2790
- trait Trait {
2790
+ trait T1 {
2791
2791
type Bar;
2792
2792
}
2793
2793
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
+ }
2796
2804
```
2797
2805
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
2799
2808
associated type name. Example:
2800
2809
2801
2810
```
2802
- trait Trait {
2811
+ trait T1 {
2803
2812
type Bar;
2804
2813
}
2805
2814
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
+ }
2807
2826
```
2808
2827
"## ,
2809
2828
You can’t perform that action at this time.
0 commit comments