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

myclassobj.meth unsafely copies myclassobj #2436

Closed
paulstansifer opened this issue May 24, 2012 · 4 comments
Closed

myclassobj.meth unsafely copies myclassobj #2436

paulstansifer opened this issue May 24, 2012 · 4 comments
Labels
A-typesystem Area: The type system
Milestone

Comments

@paulstansifer
Copy link
Contributor

The "illegally copies" line should be an error.

resource r(i: int) {}

class c {
    let dont_copy_me: r; //dummy; to prevent copying
    let mut counter: int;

    new() { }

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

fn main() {
    let c1 = c();
    c1.next();
    c1.next();
    c1.next();
    let f1 = c1.next; // illegally copies
    let f2 = c1.next;
    io::println(#fmt["%?",f1()]); // prints "4"
    io::println(#fmt["%?",f2()]); // prints "4" ) :
}
@nikomatsakis
Copy link
Contributor

This is related to the method call syntax I was raising earlier...I am more opposed to a.b implicitly creating a closure than ever. :)

@pcwalton
Copy link
Contributor

pcwalton commented Aug 7, 2012

@nikomatsakis Is this fixed now, since a.b does not implicitly create a closure?

@eholk
Copy link
Contributor

eholk commented Aug 7, 2012

I bet this is a dup of #2548.

@msullivan
Copy link
Contributor

This is both probably a dup and invalid for other reasons now.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
fix build.rs invoking RUSTC to do check builds

This makes the Miri driver, when invokved via the RUSTC env var from inside a build script, behave almost entirely like rustc. I had to redo how we propagate sysroot information for this (which is actually back to how we used to do sysroot propagation many years ago).

Fixes rust-lang/miri#2431
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

5 participants