1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(box_syntax)]
13 struct Foo { a: isize, b: isize }
16 let mut x
: Box
<_
> = box Foo { a: 1, b: 2 }
;
17 let (a
, b
) = (&mut x
.a
, &mut x
.b
);
18 //~^ ERROR cannot borrow `x` (here through borrowing `x.b`) as mutable more than once at a time
19 //~^^ NOTE previous borrow of `x` occurs here (through borrowing `x.a`)
21 let mut foo
: Box
<_
> = box Foo { a: 1, b: 2 }
;
22 let (c
, d
) = (&mut foo
.a
, &foo
.b
);
23 //~^ ERROR cannot borrow `foo` (here through borrowing `foo.b`) as immutable
24 //~^^ NOTE previous borrow of `foo` occurs here (through borrowing `foo.a`)
26 //~^ NOTE previous borrow ends here
27 //~^^ NOTE previous borrow ends here