Rust errors / Build and Cargo
Rust build error · checked with Rust 1.99.0
error[E0752]: `main` function is not allowed to be `async`
error[E0752]: `main` function is not allowed to be `async`
What it meansRust has no built-in async runtime, so main cannot be async on its own. A runtime macro like tokio::main turns it into a normal main that runs your async code.
Why it happens
- Writing async fn main() without a runtime attribute.
- tokio added without the macros and rt-multi-thread features.
How to fix it
1. Use tokio's main macro
cargo add tokio --features full
#[tokio::main]
async fn main() {
// async code here
}Other wordings of this error
main function is not allowed to be async, async fn main not allowed, E0752
Other build errors
- error: linker `link.exe` not found
- error: linker `cc` not found
- error: failed to run custom build command for `openssl-sys`
- error: failed to select a version for the requirement
- error: failed to select a version for `libsqlite3-sys`... the package `libsqlite3-sys` lin
- error: could not compile `my-crate` (bin "my-crate") due to 1 previous error
- error: package `foo v1.2.3` cannot be built because it requires rustc 1.80 or newer, while
- feature `edition2024` is required
Up next
Find the right pagePaste any Rust errorCompiler codes and build errors in one finder.Read it next →Also worth your time
Did this answer your question?