Skip to content

ICE: nightly async_closure "leftover child captures?" #124483

@finnbear

Description

@finnbear

Code

#![feature(async_closure)]

fn main() {
    let bar = 0;
    async |inner| {
        bar;
    };
}

(I arrived at this particular ICE-producing code while minimizing a different ICE)

Meta

rustc 1.79.0-nightly (aed2187d5 2024-04-27)

Related: #62290

Error output

thread 'rustc' panicked at /rustc/aed2187d53b8789e3a37f50ae36f894a2a679077/compiler/rustc_middle/src/ty/closure.rs:469:13:
assertion `left == right` failed: leftover child captures?
  left: Some((0, CapturedPlace { var_ident: bar#0, place: Place { base_ty: i32, base: Upvar(UpvarId(HirId(DefId(0:3 ~ playground[2684]::main).4);`bar`;DefId(0:5 ~ playground[2684]::main::{closure#0}::{closure#0}))), projections: [] }, info: CaptureInfo { capture_kind_expr_id: Some(HirId(DefId(0:3 ~ playground[2684]::main).18)), path_expr_id: Some(HirId(DefId(0:3 ~ playground[2684]::main).18)), capture_kind: ByRef(ImmBorrow) }, mutability: Not, region: Some('?0) }))
 right: None

For comprehensive backtrace, see: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=0b55c6cfb1b792d1561c8e6398f48faf

Thanks for investigating this! Feel free to close this if ICE while compiling broken nightly-only code is tolerable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler 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