Skip to content

ICE with move FnOnce unboxed closure #18652

Closed
@cristicbz

Description

@cristicbz
#![feature(unboxed_closures)]

struct Foo;
impl Foo {
    fn bar(&self, _x: uint) {}
}

fn main() {
    let foo = Foo;
    let y = 0u;
    move |:| {
        foo.bar(y);
    };
}

Gives:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. 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' panicked at 'assertion failed: freevars.len() <= 1', /build/rust-git/src/rust/src/librustc/middle/trans/closure.rs:325

Rust playpen

Foo.bar can take &self or &mut self instead and the ICE still happens. The following things stop the ICE from happening:

  • Moving foo or y inside the closure.
  • Removing foo (capturing only y).
  • Removing y (capturing only foo)
  • Making the closure non-move, |&:| or |& mut:|.

Only have access to the playpen right now, so I can't get a backtrace, sorry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions