Skip to content

{|| ... x ...} unsafely copies x #2437

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
paulstansifer opened this issue May 24, 2012 · 2 comments
Closed

{|| ... x ...} unsafely copies x #2437

paulstansifer opened this issue May 24, 2012 · 2 comments
Labels
A-type-system Area: Type system

Comments

@paulstansifer
Copy link
Contributor

Oops, turns out this was already fixed. Never mind!

@eholk
Copy link
Contributor

eholk commented May 24, 2012

Did you run code that makes sure this is actually fixed? It wouldn't hurt to make sure.

@paulstansifer
Copy link
Contributor Author

This code is the code I was about to paste into the issue, until I discovered it was correctly erroring.

resource r(i: int) {}

class c {
    let dont_copy_me: r;
    let mut counter: int;

    new() { }

    fn next() -> int {
        self.counter += 1;
        ret self.counter;
    }

    fn breakit() {
        let f1 = {|| self.next()};
        let f2 = {|| self.next()};
        io::println(#fmt["%?",f1()]);
        io::println(#fmt["%?",f2()]);
    }
}

fn main() {
    let c1 = c();
    c1.next();
    c1.next();
    c1.next();
    c1.breakit();
}

celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
There is no need for a different visitor for gathering unit tests.
tshepang added a commit to tshepang/rust that referenced this issue Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants