]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs
1 #![feature(bindings_after_at)]
2 #![feature(move_ref_pattern)]
11 ref mut z @
&mut Some(ref a
) => {
12 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
13 //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
25 fn f1(ref a @
ref mut b
: U
) {}
26 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
27 fn f2(ref mut a @
ref b
: U
) {}
28 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
29 fn f3(ref a @
[ref b
, ref mut mid @
.., ref c
]: [U
; 4]) {}
30 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
31 fn f4_also_moved(ref a @
ref mut b @ c
: U
) {}
32 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
33 //~| ERROR cannot move out of value because it is borrowed
35 let ref mut a @
(ref b @
ref mut c
) = u(); // sub-in-sub
36 //~^ ERROR cannot borrow value as mutable more than once at a time
37 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
39 let ref a @
ref mut b
= U
;
40 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
41 let ref mut a @
ref b
= U
;
42 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
43 let ref a @
(ref mut b
, ref mut c
) = (U
, U
);
44 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
45 let ref mut a @
(ref b
, ref c
) = (U
, U
);
46 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
48 let ref mut a @
ref b
= u();
49 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
50 //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
53 let ref a @
ref mut b
= u();
54 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
55 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
59 let ref mut a @
ref b
= U
;
60 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
63 let ref a @
ref mut b
= U
;
64 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
69 ref mut a @
Ok(ref b
) | ref mut a @
Err(ref b
) => {
70 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
71 //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
78 ref a @
Ok(ref mut b
) | ref a @
Err(ref mut b
) => {
79 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
80 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
81 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
82 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
89 ref a @
Ok(ref mut b
) | ref a @
Err(ref mut b
) if { *b = U; false }
=> {}
90 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
91 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
92 //~| ERROR cannot assign to `*b`, as it is immutable for the pattern guard
96 ref mut a @
Ok(ref b
) | ref mut a @
Err(ref b
) if { *a = Err(U); false }
=> {}
97 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
98 //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
99 //~| ERROR cannot assign to `*a`, as it is immutable for the pattern guard
103 ref a @
Ok(ref mut b
) | ref a @
Err(ref mut b
) if { drop(b); false }
=> {}
104 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
105 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
106 //~| ERROR cannot move out of `b` in pattern guard
107 //~| ERROR cannot move out of `b` in pattern guard
111 ref mut a @
Ok(ref b
) | ref mut a @
Err(ref b
) if { drop(a); false }
=> {}
112 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
113 //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
114 //~| ERROR cannot move out of `a` in pattern guard
115 //~| ERROR cannot move out of `a` in pattern guard
119 let ref a @
(ref mut b
, ref mut c
) = (U
, U
);
120 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
124 let ref a @
(ref mut b
, ref mut c
) = (U
, U
);
125 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
126 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
127 //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
131 let ref a @
(ref mut b
, ref mut c
) = (U
, U
);
132 //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
133 *b
= U
; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
134 *c
= U
; //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
136 let ref mut a @
(ref b
, ref c
) = (U
, U
);
137 //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable