diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /compiler/rustc_error_codes/src/error_codes/E0220.md | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0220.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0220.md | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0220.md b/compiler/rustc_error_codes/src/error_codes/E0220.md new file mode 100644 index 000000000..ddc54007c --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0220.md @@ -0,0 +1,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; +} +``` |