Skip to content

librustc: Add a hack to allow unboxed closures to achieve the 'static #16622

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
wants to merge 1 commit into from

Conversation

pcwalton
Copy link
Contributor

bound if possible.

Closes #16560.

r? @nikomatsakis

@lilyball
Copy link
Contributor

This patch fixes a bit of test code that doesn't compile on latest master:

#![feature(unboxed_closures)]

struct Dropper {
    msg: &'static str
}

impl Dropper {
    fn new(msg: &'static str) -> Dropper {
        Dropper {
            msg: msg
        }
    }
}

impl Drop for Dropper {
    fn drop(&mut self) {
        println!("drop: {}", self.msg);
    }
}

pub fn main() {
    let c = {
        let one = Dropper::new("one");
        let two = Dropper::new("two");
        let three = Dropper::new("three");
        |:| { let _ = (&one, &two, &three); }
    };
    println!("Dropping unboxed closure");
    drop(c);
}

Without the patch, borrowck claims that the closure's capture of its upvars will outlive the upvars.

@alexcrichton
Copy link
Member

ping @pcwalton, any update on this?

@pcwalton pcwalton closed this Sep 26, 2014
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

Successfully merging this pull request may close these issues.

Struct + Fn fulfills Send, but sugary version |&: ...| does not
5 participants