Closed
Description
Code
with edition 2015:
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `move`
--> g.rs:4:11
|
4 | async move {}();
| ^^^^ expected one of 8 possible tokens
error: aborting due to previous error
with edition 2018:
error[E0618]: expected function, found `[async block@g.rs:4:5: 4:18]`
--> g.rs:4:5
|
4 | async move {}();
| ^^^^^^^^^^^^^--
| |
| call expression requires function
error: aborting due to previous error
with edition < 2018, we could suggest switching to a later edition instead of throwing an obscure syntax error.
original code:
// edition: 2021
// check-pass
// This test verifies that we do not create a query cycle when typechecking has several inference
// variables that point to the same generator interior type.
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
type ChannelTask = Pin<Box<dyn Future<Output = ()> + Send>>;
pub fn register_message_type() -> ChannelTask {
Box::pin(async move {
let f = |__cx: &mut Context<'_>| Poll::<()>::Pending;
PollFn { f }.await
})
}
struct PollFn<F> {
f: F,
}
impl<F> Unpin for PollFn<F> {}
impl<T, F> Future for PollFn<F>
where
F: FnMut(&mut Context<'_>) -> Poll<T>,
{
type Output = T;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
(&mut self.f)(cx)
}
}
fn main() {}
```
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.