]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrow-tuple-fields.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / borrowck / borrow-tuple-fields.rs
CommitLineData
c295e0f8
XL
1struct Foo(Box<isize>, isize);
2
3struct Bar(isize, isize);
1a4d82fc 4
b7449926
XL
5
6
1a4d82fc 7
1a4d82fc
JJ
8
9fn main() {
c295e0f8 10 let x: (Box<_>, _) = (Box::new(1), 2);
1a4d82fc
JJ
11 let r = &x.0;
12 let y = x; //~ ERROR cannot move out of `x` because it is borrowed
13
b7449926
XL
14 r.use_ref();
15
85aaf69f 16 let mut x = (1, 2);
1a4d82fc
JJ
17 let a = &x.0;
18 let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
b7449926 19 a.use_ref();
1a4d82fc 20
85aaf69f 21 let mut x = (1, 2);
1a4d82fc
JJ
22 let a = &mut x.0;
23 let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
b7449926 24 a.use_ref();
1a4d82fc 25
c295e0f8 26 let x = Foo(Box::new(1), 2);
1a4d82fc
JJ
27 let r = &x.0;
28 let y = x; //~ ERROR cannot move out of `x` because it is borrowed
b7449926 29 r.use_ref();
1a4d82fc 30
85aaf69f 31 let mut x = Bar(1, 2);
1a4d82fc
JJ
32 let a = &x.0;
33 let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
b7449926 34 a.use_ref();
1a4d82fc 35
85aaf69f 36 let mut x = Bar(1, 2);
1a4d82fc
JJ
37 let a = &mut x.0;
38 let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
b7449926 39 a.use_mut();
1a4d82fc 40}
b7449926
XL
41
42trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
43impl<T> Fake for T { }