1 // Test that `ref mut x @ ref mut y` and varieties of that are not allowed.
3 #![feature(bindings_after_at)]
4 #![feature(slice_patterns)]
11 fn f1(ref mut a @ ref mut b: U) {}
12 //~^ ERROR cannot borrow `a` as mutable more than once at a time
13 fn f2(ref mut a @ ref mut b: U) {}
14 //~^ ERROR cannot borrow `a` as mutable more than once at a time
17 //~^ ERROR cannot borrow `a` as mutable more than once at a time
19 [_, ref mut mid @ ..],
25 let ref mut a @ ref mut b = U;
26 //~^ ERROR cannot borrow `a` as mutable more than once at a time
27 //~| ERROR cannot borrow `_` as mutable more than once at a time
29 let ref mut a @ ref mut b = U;
30 //~^ ERROR cannot borrow `a` as mutable more than once at a time
32 let ref mut a @ ref mut b = U;
33 //~^ ERROR cannot borrow `a` as mutable more than once at a time
35 let ref mut a @ ref mut b = U;
36 //~^ ERROR cannot borrow `a` as mutable more than once at a time
37 //~| ERROR cannot borrow `_` as mutable more than once at a time
39 let ref mut a @ ref mut b = U;
40 //~^ ERROR cannot borrow `a` as mutable more than once at a time
44 //~^ ERROR cannot borrow `a` as mutable more than once at a time
54 //~^ ERROR cannot borrow `a` as mutable more than once at a time
61 ) = (u(), [u(), u(), u()]);
63 let a @ (ref mut b, ref mut c) = (U, U);
64 //~^ ERROR cannot bind by-move with sub-bindings
65 //~| ERROR borrow of moved value
66 let mut val = (U, [U, U]);
67 let a @ (b, [c, d]) = &mut val; // Same as ^--
68 //~^ ERROR cannot bind by-move with sub-bindings
69 //~| ERROR borrow of moved value
71 let a @ &mut ref mut b = &mut U;
72 //~^ ERROR cannot bind by-move with sub-bindings
73 //~| ERROR borrow of moved value
74 let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
75 //~^ ERROR cannot bind by-move with sub-bindings
76 //~| ERROR borrow of moved value
79 ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
80 //~^ ERROR cannot borrow `a` as mutable more than once at a time
81 //~| ERROR cannot borrow `a` as mutable more than once at a time
85 ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
86 //~^ ERROR cannot borrow `a` as mutable more than once at a time
87 //~| ERROR cannot borrow `a` as mutable more than once at a time
92 ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
93 //~^ ERROR cannot borrow `a` as mutable more than once at a time
94 //~| ERROR cannot borrow `a` as mutable more than once at a time
95 //~| ERROR cannot borrow `_` as mutable more than once at a time
96 //~| ERROR cannot borrow `_` as mutable more than once at a time
99 // FIXME: The binding name `_` used above makes for problematic diagnostics.
100 // Resolve that somehow...
104 ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
105 //~^ ERROR cannot borrow `a` as mutable more than once at a time
106 //~| ERROR cannot borrow `a` as mutable more than once at a time
107 //~| ERROR cannot borrow `_` as mutable more than once at a time
108 //~| ERROR cannot borrow `_` as mutable more than once at a time