Closed
Description
I tried this code:
#![feature(type_alias_impl_trait)]
#![no_std]
pub trait Tr<'x> {
type Fut: core::future::Future<Output = ()>;
fn f() -> Self::Fut;
}
impl<'x> Tr<'x> for () {
type Fut = impl core::future::Future<Output = ()>;
fn f() -> Self::Fut {
async {
//if false {
return ();
//}
let res: Undef = ();
res
}
}
}
When I check this file with rustc async.rs --crate-type lib
, rust errors
--> async.rs:16:13
|
14 | async {
| ----- `async` blocks are only allowed in Rust 2018 or later
15 | //if false {
16 | return ();
| ^^^^^^ expected identifier, found keyword
|
= help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
Which is a bit confusing.
Does it want me to set edition = 2021
in Cargo.toml (as in "please set edition = 2021...")?
Why does it complain about a Cargo.toml when there isn't one (as I just checked the file directly with rustc x.rs).
For some other examples, the message is even more confusing
= note: to `.await` a `Future`, switch to Rust 2018 or later
= help: set `edition = "2021"` in `Cargo.toml`
because it is not clear if rustc want to say "2021 is set" or "2021 should be set"