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

Can't pass a POD field by value to a &mut self method #15021

Closed
kmcallister opened this issue Jun 18, 2014 · 2 comments
Closed

Can't pass a POD field by value to a &mut self method #15021

kmcallister opened this issue Jun 18, 2014 · 2 comments

Comments

@kmcallister
Copy link
Contributor

struct Foo {
    x: uint,
}

impl Foo {
    fn bar(&mut self, x: uint) { }
}

fn main() {
    let mut foo = Foo { x: 0 };
    foo.bar(foo.x);
}
foo.rs:11:13: 11:18 error: cannot use `foo.x` because it was mutably borrowed
foo.rs:11     foo.bar(foo.x);
                      ^~~~~
foo.rs:11:5: 11:8 note: borrow of `foo` occurs here
foo.rs:11     foo.bar(foo.x);
              ^~~
error: aborting due to previous error

This is a regression somewhere between e55f64f and 557b9e7.

@zwarich
Copy link

zwarich commented Jun 18, 2014

This was d7de4e9. Making this work again is #6268, but for now you can use a let binding.

@alexcrichton
Copy link
Member

Closing as a dupe of #6268

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

3 participants