Skip to content

mutably captured default int emits type inference error in closure #21347

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

Closed
blaenk opened this issue Jan 18, 2015 · 1 comment
Closed

mutably captured default int emits type inference error in closure #21347

blaenk opened this issue Jan 18, 2015 · 1 comment

Comments

@blaenk
Copy link
Contributor

blaenk commented Jan 18, 2015

Really had no idea what to call this, feel free to change. As soon as I annotate the type of i when I create it or when I add to it, it works. I of course intended to annotate the type, but I did notice this and figured I'd post it in case it's not intentional.

extern crate libc;

fn main() {
    fn f<F>(f: F) where F: FnMut(&str) {
      let down = &f as *const _ as *mut libc::c_void;
      let up = down as *mut F;
      let s = "lol what";
      unsafe { (*up)(s); }
    }

    let mut i = 3;

    f(|&mut: data: &str| {
        println!("data is: {}", data);
        i += 3;
    });

    println!("i is now: {}", i);
}

Error:

<anon>:13:5: 13:6 error: unable to infer enough type information about `closure[<anon>:13:7: 16:6]`; type annotations required
<anon>:13     f(|&mut: data: &str| {
              ^
error: aborting due to previous error
playpen: application terminated with error code 101

playpen

@blaenk blaenk closed this as completed Jan 18, 2015
@blaenk blaenk reopened this Jan 18, 2015
@Aatch
Copy link
Contributor

Aatch commented Jan 18, 2015

Dupe of #20558

@Aatch Aatch closed this as completed Jan 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants