]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / borrowck-borrow-from-stack-variable.stderr
1 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
2   --> $DIR/borrowck-borrow-from-stack-variable.rs:28:22
3    |
4 LL |     let bar1 = &mut foo.bar1;
5    |                     -------- first mutable borrow occurs here
6 LL |     let _bar2 = &mut foo.bar1;  //~ ERROR cannot borrow
7    |                      ^^^^^^^^ second mutable borrow occurs here
8 LL |     *bar1;
9 LL | }
10    | - first borrow ends here
11
12 error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
13   --> $DIR/borrowck-borrow-from-stack-variable.rs:35:18
14    |
15 LL |     let bar1 = &mut foo.bar1;
16    |                     -------- mutable borrow occurs here
17 LL |     let _bar2 = &foo.bar1;  //~ ERROR cannot borrow
18    |                  ^^^^^^^^ immutable borrow occurs here
19 LL |     *bar1;
20 LL | }
21    | - mutable borrow ends here
22
23 error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
24   --> $DIR/borrowck-borrow-from-stack-variable.rs:42:22
25    |
26 LL |     let bar1 = &foo.bar1;
27    |                 -------- immutable borrow occurs here
28 LL |     let _bar2 = &mut foo.bar1;  //~ ERROR cannot borrow
29    |                      ^^^^^^^^ mutable borrow occurs here
30 LL |     *bar1;
31 LL | }
32    | - immutable borrow ends here
33
34 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
35   --> $DIR/borrowck-borrow-from-stack-variable.rs:71:21
36    |
37 LL |     let bar1 = &mut foo.bar1;
38    |                     -------- first mutable borrow occurs here
39 LL |     match foo {
40 LL |         Foo { bar1: ref mut _bar1, bar2: _ } => {} //
41    |                     ^^^^^^^^^^^^^ second mutable borrow occurs here
42 ...
43 LL | }
44    | - first borrow ends here
45
46 error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable
47   --> $DIR/borrowck-borrow-from-stack-variable.rs:80:18
48    |
49 LL |     let bar1 = &mut foo.bar1.int1;
50    |                     ------------- mutable borrow occurs here
51 LL |     let _foo1 = &foo.bar1; //~ ERROR cannot borrow
52    |                  ^^^^^^^^ immutable borrow occurs here
53 ...
54 LL | }
55    | - mutable borrow ends here
56
57 error[E0502]: cannot borrow `foo` as immutable because `foo.bar1.int1` is also borrowed as mutable
58   --> $DIR/borrowck-borrow-from-stack-variable.rs:81:18
59    |
60 LL |     let bar1 = &mut foo.bar1.int1;
61    |                     ------------- mutable borrow occurs here
62 LL |     let _foo1 = &foo.bar1; //~ ERROR cannot borrow
63 LL |     let _foo2 = &foo; //~ ERROR cannot borrow
64    |                  ^^^ immutable borrow occurs here
65 LL |     *bar1;
66 LL | }
67    | - mutable borrow ends here
68
69 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
70   --> $DIR/borrowck-borrow-from-stack-variable.rs:88:22
71    |
72 LL |     let bar1 = &mut foo.bar1.int1;
73    |                     ------------- first mutable borrow occurs here
74 LL |     let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
75    |                      ^^^^^^^^ second mutable borrow occurs here
76 LL |     *bar1;
77 LL | }
78    | - first borrow ends here
79
80 error[E0499]: cannot borrow `foo` as mutable more than once at a time
81   --> $DIR/borrowck-borrow-from-stack-variable.rs:95:22
82    |
83 LL |     let bar1 = &mut foo.bar1.int1;
84    |                     ------------- first mutable borrow occurs here
85 LL |     let _foo2 = &mut foo; //~ ERROR cannot borrow
86    |                      ^^^ second mutable borrow occurs here
87 LL |     *bar1;
88 LL | }
89    | - first borrow ends here
90
91 error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable
92   --> $DIR/borrowck-borrow-from-stack-variable.rs:102:22
93    |
94 LL |     let bar1 = &foo.bar1.int1;
95    |                 ------------- immutable borrow occurs here
96 LL |     let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
97    |                      ^^^^^^^^ mutable borrow occurs here
98 LL |     *bar1;
99 LL | }
100    | - immutable borrow ends here
101
102 error[E0502]: cannot borrow `foo` as mutable because `foo.bar1.int1` is also borrowed as immutable
103   --> $DIR/borrowck-borrow-from-stack-variable.rs:109:22
104    |
105 LL |     let bar1 = &foo.bar1.int1;
106    |                 ------------- immutable borrow occurs here
107 LL |     let _foo2 = &mut foo; //~ ERROR cannot borrow
108    |                      ^^^ mutable borrow occurs here
109 LL |     *bar1;
110 LL | }
111    | - immutable borrow ends here
112
113 error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable
114   --> $DIR/borrowck-borrow-from-stack-variable.rs:130:21
115    |
116 LL |     let foo = make_foo();
117    |         --- help: make this binding mutable: `mut foo`
118 LL |     let bar1 = &mut foo.bar1; //~ ERROR cannot borrow
119    |                     ^^^^^^^^ cannot mutably borrow field of immutable binding
120
121 error: aborting due to 11 previous errors
122
123 Some errors occurred: E0499, E0502, E0596.
124 For more information about an error, try `rustc --explain E0499`.