Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0799: expected type or const parameter, found function `main`
What it meansSomething other than a type or const parameter has been used when one was expected.
What rustc prints
error[E0799]: expected type or const parameter, found function `main`
--> main.rs:1:31
|
1 | fn bad1() -> impl Sized + use<main> {}
| ^^^^ not a type or const parameterReal 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
Something other than a type or const parameter has been used when one was expected.
Erroneous code example:
fn bad1() -> impl Sized + use<main> {}
fn bad2(x: ()) -> impl Sized + use<x> {}
fn main() {}
In the given examples, for bad1, the name main corresponds to a function rather than a type or const parameter. In bad2, the name x corresponds to a function argument rather than a type or const parameter.
Only type and const parameters, including Self, may be captured by use<...> precise capturing bounds.
From rustc --explain E0799 (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
- E0791invalid type for variable with `#[linkage]` attribute
- E0792expected generic type parameter, found `u32`
- E0800cannot find type or const parameter `T` in this scope
- E0801invalid generic `self` parameter type: `R`
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?