1 // Copyright 2012 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.
21 fn borrow_same_field_twice_mut_mut(foo: &mut Foo) {
22 let _bar1 = &mut foo.bar1;
23 let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
26 fn borrow_same_field_twice_mut_imm(foo: &mut Foo) {
27 let _bar1 = &mut foo.bar1;
28 let _bar2 = &foo.bar1; //~ ERROR cannot borrow
31 fn borrow_same_field_twice_imm_mut(foo: &mut Foo) {
32 let _bar1 = &foo.bar1;
33 let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
36 fn borrow_same_field_twice_imm_imm(foo: &mut Foo) {
37 let _bar1 = &foo.bar1;
38 let _bar2 = &foo.bar1;
41 fn borrow_both_mut(foo: &mut Foo) {
42 let _bar1 = &mut foo.bar1;
43 let _bar2 = &mut foo.bar2;
46 fn borrow_both_mut_pattern(foo: &mut Foo) {
48 Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {}
52 fn borrow_var_and_pattern(foo: &mut Foo) {
53 let _bar1 = &mut foo.bar1;
55 Foo { bar1: ref mut _bar1, bar2: _ } => {}
56 //~^ ERROR cannot borrow
60 fn borrow_mut_and_base_imm(foo: &mut Foo) {
61 let _bar1 = &mut foo.bar1.int1;
62 let _foo1 = &foo.bar1; //~ ERROR cannot borrow
63 let _foo2 = &*foo; //~ ERROR cannot borrow
66 fn borrow_mut_and_base_mut(foo: &mut Foo) {
67 let _bar1 = &mut foo.bar1.int1;
68 let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
71 fn borrow_mut_and_base_mut2(foo: &mut Foo) {
72 let _bar1 = &mut foo.bar1.int1;
73 let _foo2 = &mut *foo; //~ ERROR cannot borrow
76 fn borrow_imm_and_base_mut(foo: &mut Foo) {
77 let _bar1 = &foo.bar1.int1;
78 let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
81 fn borrow_imm_and_base_mut2(foo: &mut Foo) {
82 let _bar1 = &foo.bar1.int1;
83 let _foo2 = &mut *foo; //~ ERROR cannot borrow
86 fn borrow_imm_and_base_imm(foo: &mut Foo) {
87 let _bar1 = &foo.bar1.int1;
88 let _foo1 = &foo.bar1;
92 fn borrow_mut_and_imm(foo: &mut Foo) {
93 let _bar1 = &mut foo.bar1;
94 let _foo1 = &foo.bar2;
97 fn borrow_mut_from_imm(foo: &Foo) {
98 let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow
101 fn borrow_long_path_both_mut(foo: &mut Foo) {
102 let _bar1 = &mut foo.bar1.int1;
103 let _foo1 = &mut foo.bar2.int2;