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

Use of raw pointer as self parameter #26194

Closed
eefriedman opened this issue Jun 10, 2015 · 1 comment · Fixed by #26225
Closed

Use of raw pointer as self parameter #26194

eefriedman opened this issue Jun 10, 2015 · 1 comment · Fixed by #26225

Comments

@eefriedman
Copy link
Contributor

Testcase:

struct S(String);
impl S {
    fn f(self: *mut S) -> String { self.0 } 
}
fn main() { S("".to_owned()).f(); }

This somehow compiles and runs without any errors.

I'm not sure how exactly this is getting interpreted by the compiler, but it seems dubious at best.

@Veedrac
Copy link
Contributor

Veedrac commented Jun 10, 2015

self is of type S inside the function, and seems to be moved "correctly".

s.f();
s.f();

gives

<anon>:8:5: 8:6 error: use of moved value: `s`
<anon>:8     s.f();

whilst

fn f(self: *mut S) { let _: () = self; }

gives

<anon>:3:38: 3:42 error: mismatched types:
 expected `()`,
    found `S`

arielb1 pushed a commit to arielb1/rust that referenced this issue Jun 11, 2015
This can't be made to work with the current setup.

Fixes rust-lang#26194.
bors added a commit that referenced this issue Jun 12, 2015
This can't be made to work with the current setup.

Technically a [breaking-change], but a simple bug fix.

Fixes #26194.
mikeyhew added a commit to mikeyhew/rust that referenced this issue Dec 17, 2017
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 a pull request may close this issue.

3 participants