I'm trying to compile a library in Rust and I get an error:
error[E0670]: `async fn` is not permitted in Rust 2015
--> src/lib.rs:1:1
|
1 | async fn foo() {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: set `edition = "2021"` in `Cargo.toml`
This is my Cargo.toml:
[package]
name = "name"
version = "0.1.0"
edition = "2018"
and to compile I use the following command line (documentation here):
rustc --crate-type=lib src/apis/my_file.rs
Does anyone have an idea?
As the name implies Cargo.toml
is interpreted by cargo
, not rustc
if you want to compile with rustc
you have to add the edition flag:
rustc --edition=2018 --crate-type=lib src/apis/my_file.rs