Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0131: the `main` function was defined with generic parameters
What it meansThe main function was defined with generic parameters.
The compiler team's explanation
The main function was defined with generic parameters.
Erroneous code example:
fn main<T>() { // error: main function is not allowed to have generic parameters
}
It is not possible to define the main function with generic parameters. It must not take any arguments.
From rustc --explain E0131 (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
- E0121the placeholder `_` is not allowed within types on item signatures for return types
- E0128generic parameter defaults cannot reference parameters before they are declared
- E0158constant pattern cannot depend on generic parameters
- E0170pattern binding `GET` is named the same as one of the variants of the type `Method`
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?