Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0719: the value of the associated type `Item` in trait `Iterator` is already specified
What it meansAn associated item was specified more than once in a trait object.
What rustc prints
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
--> main.rs:5:37
|
5 | type Foo = dyn Iterator<Item = u32, Item = u32>;
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here firstReal output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.
The compiler team's explanation
An associated item was specified more than once in a trait object.
Erroneous code example:
trait FooTrait {}
trait BarTrait {}
// error: associated type `Item` in trait `Iterator` is specified twice
type Foo = dyn Iterator<Item = u32, Item = u32>;
To fix this, remove the duplicate specifier:
Corrected example:
type Foo = dyn Iterator<Item = u32>; // ok!
For more information about associated types, see the book. For more information on associated type bounds, see RFC 2289.
From rustc --explain E0719 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.
Related errors
- E0308mismatched types
- E0277the trait bound is not satisfied
- E0599no method named X found in the current scope
- E0433failed to resolve
- E0714marker traits cannot have associated items
- E0715impls for marker traits cannot contain items
- E0720cannot resolve opaque type
- E0735generic parameters cannot use `Self` in their defaults
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?