Skip to content

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

Description

@makoConstruct
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);
    //                   ^~~~~
}

Activity

  1. 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[/+] on Sep 15, 2014
  2. 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[/+] on Sep 15, 2014
  3. added a commit that references this issue on Oct 2, 2014
    84a4a07
  4. pnkfelix commented on Nov 6, 2018

    @pnkfelix
    Contributor

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

  5. added a commit that references this issue on Sep 25, 2024
    97907ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions