Skip to content

ICE in CFG builder with unused closure and upvars. #16256

Closed
@luqmana

Description

@luqmana

Trying to compile this results in an ICE:

fn main() {
    let mut buf = Vec::new();
    |c: u8| buf.push(c);
}
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'assertion failed: self.nodeid_to_index.contains_key(&id)', /Users/Luqman/rust/src/librustc/middle/dataflow.rs:226

Using the closure by either assigning it to a variable or just calling it makes the ICE go away. It also only seems to happen when you capture something.

cc: @pnkfelix

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions