Skip to content

Commit 9f3a192

Browse files
authored
Rollup merge of #69620 - thekuom:doc/61137-add-long-error-code-e0719, r=davidtwco
doc(librustc_error_codes): add long error explanation for E0719 Reference issue #61137 - Updated error_codes.rs - Added E0719.md in error_codes - Updated necessary test .stderr files
2 parents f19684c + 275dac7 commit 9f3a192

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ E0714: include_str!("./error_codes/E0714.md"),
395395
E0715: include_str!("./error_codes/E0715.md"),
396396
E0716: include_str!("./error_codes/E0716.md"),
397397
E0718: include_str!("./error_codes/E0718.md"),
398+
E0719: include_str!("./error_codes/E0719.md"),
398399
E0720: include_str!("./error_codes/E0720.md"),
399400
E0723: include_str!("./error_codes/E0723.md"),
400401
E0725: include_str!("./error_codes/E0725.md"),
@@ -605,7 +606,6 @@ E0748: include_str!("./error_codes/E0748.md"),
605606
E0710, // an unknown tool name found in scoped lint
606607
E0711, // a feature has been declared with conflicting stability attributes
607608
E0717, // rustc_promotable without stability attribute
608-
E0719, // duplicate values for associated type binding
609609
// E0721, // `await` keyword
610610
E0722, // Malformed `#[optimize]` attribute
611611
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
The value for an associated type has already been specified.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0719
6+
#![feature(associated_type_bounds)]
7+
8+
trait FooTrait {}
9+
trait BarTrait {}
10+
11+
// error: associated type `Item` in trait `Iterator` is specified twice
12+
struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T }
13+
```
14+
15+
`Item` in trait `Iterator` cannot be specified multiple times for struct `Foo`.
16+
To fix this, create a new trait that is a combination of the desired traits and
17+
specify the associated type with the new trait.
18+
19+
Corrected example:
20+
21+
```
22+
#![feature(associated_type_bounds)]
23+
24+
trait FooTrait {}
25+
trait BarTrait {}
26+
trait FooBarTrait: FooTrait + BarTrait {}
27+
28+
struct Foo<T: Iterator<Item: FooBarTrait>> { f: T }
29+
```
30+
31+
For more information about associated types, see [the book][bk-at]. For more
32+
information on associated type bounds, see [RFC 2289][rfc-2289].
33+
34+
[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types
35+
[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html

src/test/ui/associated-type-bounds/duplicate.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,4 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
728728

729729
error: aborting due to 96 previous errors
730730

731+
For more information about this error, try `rustc --explain E0719`.

src/test/ui/error-codes/E0719.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> {
1616

1717
error: aborting due to 2 previous errors
1818

19+
For more information about this error, try `rustc --explain E0719`.

0 commit comments

Comments
 (0)