Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected initial operand type with async closures and FnOnce #123251

Closed
compiler-errors opened this issue Mar 30, 2024 · 2 comments · Fixed by #123349
Closed

Unexpected initial operand type with async closures and FnOnce #123251

compiler-errors opened this issue Mar 30, 2024 · 2 comments · Fixed by #123349
Assignees
Labels
A-async-await Area: Async & Await F-async_closure `#![feature(async_closure)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

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,)]).
@compiler-errors compiler-errors added the F-async_closure `#![feature(async_closure)]` label Mar 30, 2024
@compiler-errors compiler-errors self-assigned this Mar 30, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 30, 2024
@compiler-errors
Copy link
Member Author

ohhhhh lol it's drop glue. Huh.

@compiler-errors
Copy link
Member Author

@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-async-await Area: Async & Await and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 31, 2024
@compiler-errors compiler-errors added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Mar 31, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 2, 2024
…ures, r=oli-obk

Fix capture analysis for by-move closure bodies

The check we were doing to figure out if a coroutine was borrowing from its parent coroutine-closure was flat-out wrong -- a misunderstanding of mine of the way that `tcx.closure_captures` represents its captures.

Fixes rust-lang#123251 (the miri/ui test I added should more than cover that issue)

r? `@oli-obk` -- I recognize that this PR may be underdocumented, so please ask me what I should explain further.
@bors bors closed this as completed in f700fb2 Apr 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 3, 2024
Rollup merge of rust-lang#123349 - compiler-errors:async-closure-captures, r=oli-obk

Fix capture analysis for by-move closure bodies

The check we were doing to figure out if a coroutine was borrowing from its parent coroutine-closure was flat-out wrong -- a misunderstanding of mine of the way that `tcx.closure_captures` represents its captures.

Fixes rust-lang#123251 (the miri/ui test I added should more than cover that issue)

r? `@oli-obk` -- I recognize that this PR may be underdocumented, so please ask me what I should explain further.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await F-async_closure `#![feature(async_closure)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants