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

confusing compile error for second partial borrows of/from Boxes, refers to members rather than box itself #17263

Closed
makoConstruct opened this issue Sep 15, 2014 · 1 comment · Fixed by #17434

Comments

@makoConstruct
Copy link

struct Thing{  a: u8,  b: u8  }
fn main(){
  let mut boxed_thing = box Thing{a:2, b:2};
  let btr = &mut boxed_thing;
  let (a, b) = (&mut btr.a, &mut btr.b);
    //error: cannot borrow `btr.b` as mutable more than once at a time
    //note: previous borrow of `btr.a` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `btr.a` until the borrow ends
    //let (a, b) = (&mut btr.a, &mut btr.b);
    //                   ^~~~~
}
@makoConstruct makoConstruct changed the title confusing compile error for second partial moves(?) from Boxes, refers to second member rather than box itself confusing compile error for second partial moves(?) from Boxes, refers to members rather than box itself Sep 15, 2014
@makoConstruct makoConstruct changed the title confusing compile error for second partial moves(?) from Boxes, refers to members rather than box itself confusing compile error for second partial borrows of/from Boxes, refers to members rather than box itself Sep 15, 2014
ftxqxd added a commit to ftxqxd/rust that referenced this issue Oct 2, 2014
bors added a commit that referenced this issue Oct 2, 2014
This was originally part of #17215.

Closes #15506.
Closes #15630.
Closes #17263.

This also partially implements #15838.
@pnkfelix
Copy link
Member

pnkfelix commented Nov 6, 2018

see also some follow-up discussion here #43234 (comment)

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.

2 participants