Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0380: auto traits cannot have associated items
What it meansAn auto trait was declared with a method or an associated item.
What rustc prints
error[E0380]: auto traits cannot have associated items
--> main.rs:2:10
|
1 | unsafe auto trait Trait {
| ----- auto traits cannot have associated items
2 | type Output; // error!
| ^^^^^^Real 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 auto trait was declared with a method or an associated item.
Erroneous code example:
unsafe auto trait Trait {
type Output; // error!
}
Auto traits cannot have methods or associated items. For more information see the opt-in builtin traits RFC.
From rustc --explain E0380 (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
- E0378the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else
- E0379functions in traits cannot be declared const
- E0390cannot define inherent `impl` for primitive types
- E0391cycle detected when computing the super clauses of `FirstTrait`
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?