Modified E0220 to show error messages for more general cases
This commit is contained in:
parent
3313e50594
commit
09ffe475e7
@ -2787,23 +2787,42 @@ fn main() {
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail
|
||||
trait Trait {
|
||||
trait T1 {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
type Foo = Trait<F=i32>; // error: associated type `F` not found for
|
||||
// `Trait`
|
||||
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;
|
||||
}
|
||||
```
|
||||
|
||||
Please verify you used the right trait or you didn't misspell the
|
||||
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 Trait {
|
||||
trait T1 {
|
||||
type Bar;
|
||||
}
|
||||
|
||||
type Foo = Trait<Bar=i32>; // ok!
|
||||
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;
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user