Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0567: auto traits cannot have generic parameters
What it meansGenerics have been used on an auto trait.
What rustc prints
error[E0567]: auto traits cannot have generic parameters
--> main.rs:3:19
|
3 | auto trait Generic<T> {} // error!
| -------^^^
| |
| auto trait cannot have generic parametersReal 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
Generics have been used on an auto trait.
Erroneous code example:
#![feature(auto_traits)]
auto trait Generic<T> {} // error!
Since an auto trait is implemented on all existing types, the compiler would not be able to infer the types of the trait's generic parameters.
To fix this issue, just remove the generics:
#![feature(auto_traits)]
auto trait Generic {} // ok!From rustc --explain E0567 (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
- E0561patterns aren't allowed in function pointer types
- E0562`impl Trait` is not allowed in the type of variable bindings
- E0569requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
- E0573expected type, found variant `Dragon::Born`
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?