Skip to content

ICE when attempting to manually implement FnMut #21461

Closed
@blaenk

Description

@blaenk

While trying to figure out how to properly implement FnMut for this struct I ran into this ICE. I still don't know how to properly implement it, chances are I was doing it wrong, but I imagine that an ICE isn't expected in any case so I decided to post this up in case it hasn't been brought up.

#![feature(unboxed_closures)]

struct VecEnv<'a> {
    vec: Vec<i32>,
}

impl<'a> FnMut(&mut i32, &i32) -> i32 for VecEnv<'a> {
    extern "rust-call" fn call_mut(&mut self, (output, text): (&mut i32, &i32)) -> i32 {
        println!("CLOSURE");
        1i32
    }
}

fn main() {}
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
thread 'rustc' panicked at 'assertion failed: !generic_bounds.has_escaping_regions()', /build/rust-git/src/rust/src/librustc_typeck/check/mod.rs:1784

playpen

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)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