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

ICE when attempting to manually implement FnMut #21461

Closed
blaenk opened this issue Jan 21, 2015 · 4 comments
Closed

ICE when attempting to manually implement FnMut #21461

blaenk opened this issue Jan 21, 2015 · 4 comments
Labels
A-closures Area: Closures (`|…| { … }`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@blaenk
Copy link
Contributor

blaenk commented Jan 21, 2015

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

@Aatch Aatch added A-closures Area: Closures (`|…| { … }`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 21, 2015
@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

No longer gets that far:

$ rustc main.rs
main.rs:7:35: 7:38 error: associated type bindings are not allowed here [E0229]
main.rs:7 impl<'a> FnMut(&mut i32, &i32) -> i32 for VecEnv<'a> {
                                            ^~~
error: aborting due to previous error

@blaenk can you update this?

@apasel422
Copy link
Contributor

I'm not sure if this can really be reproduced today. I got the following to compile:

#![feature(core, unboxed_closures)]

struct VecEnv<'a> {
    vec: Vec<i32>,
    marker: std::marker::PhantomData<&'a ()>,
}

impl<'a, 'b, 'c> FnOnce<(&'b mut i32, &'c i32)> for VecEnv<'a> {
    type Output = i32;

    extern "rust-call" fn call_once(self, (output, text): (&'b mut i32, &'c i32)) -> i32 {
        println!("CLOSURE");
        1i32
    }
}

fn main() {}

@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

@apasel422

They used the "impl Fn(i32) -> i32 for XYZ" syntax.

@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

duplicate of #24682 + #26638.

@arielb1 arielb1 closed this as completed Oct 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants