]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-17263.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-17263.rs
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.
4 //
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.
10
11 #![feature(box_syntax)]
12
13 struct Foo { a: isize, b: isize }
14
15 fn main() {
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`)
20
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`)
25 }
26 //~^ NOTE previous borrow ends here
27 //~^^ NOTE previous borrow ends here