diff options
| author | Jules Bertholet <julesbertholet@quoi.xyz> | 2025-09-15 09:42:14 -0400 |
|---|---|---|
| committer | Jules Bertholet <julesbertholet@quoi.xyz> | 2025-09-18 09:16:58 -0400 |
| commit | 389907a17e5c1eecd9fe41a53ca145f42dcd1488 (patch) | |
| tree | abe78240e5cfa196a16938b38437f43201a58257 /compiler/rustc_error_codes/src | |
| parent | 97a987f14c5bd948f7ee8dba75999f104a6f03a7 (diff) | |
| download | rust-389907a17e5c1eecd9fe41a53ca145f42dcd1488.tar.gz rust-389907a17e5c1eecd9fe41a53ca145f42dcd1488.zip | |
Enforce E0719 only for trait aliases
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0719.md | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0719.md b/compiler/rustc_error_codes/src/error_codes/E0719.md index cd981db1058..17cbd2de49e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0719.md +++ b/compiler/rustc_error_codes/src/error_codes/E0719.md @@ -1,4 +1,4 @@ -An associated type value was specified more than once. +An associated item value was specified more than once in a trait object. Erroneous code example: @@ -7,21 +7,15 @@ trait FooTrait {} trait BarTrait {} // error: associated type `Item` in trait `Iterator` is specified twice -struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T } +type Foo = dyn Iterator<Item = u32, Item = u32>; ``` -`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. +To fix this, remove the duplicate specifier: Corrected example: ``` -trait FooTrait {} -trait BarTrait {} -trait FooBarTrait: FooTrait + BarTrait {} - -struct Foo<T: Iterator<Item: FooBarTrait>> { f: T } // ok! +type Foo = dyn Iterator<Item = u32>; // ok! ``` For more information about associated types, see [the book][bk-at]. For more |
