-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(librustc_error_codes): add long error explanation for E0719
Progresses #61137
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
The value for an associated type has already been specified. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0719 | ||
#![feature(associated_type_bounds)] | ||
trait FooTrait {} | ||
trait BarTrait {} | ||
// error: associated type `Item` in trait `Iterator` is specified twice | ||
struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T } | ||
``` | ||
|
||
`Item` in trait `Iterator` cannot be specified multiple times for struct `Foo`. | ||
To fix this, create a new trait that is a combination of the desired traits and | ||
specify the associated type with the new trait. | ||
|
||
Corrected example: | ||
|
||
``` | ||
#![feature(associated_type_bounds)] | ||
trait FooTrait {} | ||
trait BarTrait {} | ||
trait FooBarTrait: FooTrait + BarTrait {} | ||
struct Foo<T: Iterator<Item: FooBarTrait>> { f: T } | ||
``` | ||
|
||
For more information about associated types, see [the book][bk-at]. For more | ||
information on associated type bounds, see [RFC 2289][rfc-2289]. | ||
|
||
[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types | ||
[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters