1 // ignore-tidy-linelength
11 let mut u = U { b: 0 };
12 // Imm borrow, same field
25 let rma = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
30 u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed
33 // Imm borrow, other field
46 let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`)
51 u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed
54 // Mut borrow, same field
57 let ra = &u.a; //~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
62 let a = u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed
67 let rma2 = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable more than once at a time
72 u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed
75 // Mut borrow, other field
78 let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`)
83 let b = u.b; //~ ERROR cannot use `u.b` because it was mutably borrowed
89 let rmb2 = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
94 u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed