Skip to content

Unexpected initial operand type with async closures and FnOnce #123251

Closed
@compiler-errors

Description

@compiler-errors

Something is still wrong w/ async call shims. I think I'm not doing the FnOnce transform correctly or something.

Putting this up so I don't forget about it, but I'll fix it.

#![feature(async_closure)]

#[inline(never)]
async fn call_once(x: impl async FnOnce()) {
    x().await
}

#[tokio::main]
async fn main() {
    let v = &1;
    call_once(async || {
        println!("{v}");
    }).await;
}
Unexpected initial operand type: expected *mut Coroutine(DefId(0:8 ~ playground[5acf]::main::{closure#0}::{closure#0}::{closure#0}), [i32, std::future::ResumeTy, (), (), CoroutineWitness(DefId(0:8 ~ playground[5acf]::main::{closure#0}::{closure#0}::{closure#0}), []), (&'{erased} i32,)]), found *mut Coroutine(DefId(0:8 ~ playground[5acf]::main::{closure#0}::{closure#0}::{closure#0}), [i32, std::future::ResumeTy, (), (), CoroutineWitness(DefId(0:8 ~ playground[5acf]::main::{closure#0}::{closure#0}::{closure#0}), []), (&'{erased} &'{erased} i32,)]).

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitA-async-closures`async || {}`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions