]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr
use structured suggestion for "missing mut" label
[rust.git] / src / test / ui / borrowck / borrowck-borrow-from-owned-ptr.stderr
1 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
2   --> $DIR/borrowck-borrow-from-owned-ptr.rs:29: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-owned-ptr.rs:36: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-owned-ptr.rs:43: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` (via `foo.bar2`) as mutable more than once at a time
35   --> $DIR/borrowck-borrow-from-owned-ptr.rs:57:22
36    |
37 LL |     let bar1 = &mut foo.bar1;
38    |                     -------- first mutable borrow occurs here (via `foo.bar1`)
39 LL |     let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow
40    |                      ^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`)
41 LL |     *bar1;
42 LL | }
43    | - first borrow ends here
44
45 error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time
46   --> $DIR/borrowck-borrow-from-owned-ptr.rs:64:42
47    |
48 LL |         Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {}
49    |                     -------------        ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`)
50    |                     |
51    |                     first mutable borrow occurs here (via `foo.bar1`)
52 LL |         //~^ ERROR cannot borrow
53 LL |     }
54    |     - first borrow ends here
55
56 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
57   --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:21
58    |
59 LL |     let bar1 = &mut foo.bar1;
60    |                     -------- first mutable borrow occurs here
61 LL |     match *foo {
62 LL |         Foo { bar1: ref mut _bar1, bar2: _ } => {}
63    |                     ^^^^^^^^^^^^^ second mutable borrow occurs here
64 ...
65 LL | }
66    | - first borrow ends here
67
68 error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable
69   --> $DIR/borrowck-borrow-from-owned-ptr.rs:82:18
70    |
71 LL |     let bar1 = &mut foo.bar1.int1;
72    |                     ------------- mutable borrow occurs here
73 LL |     let _foo1 = &foo.bar1; //~ ERROR cannot borrow
74    |                  ^^^^^^^^ immutable borrow occurs here
75 ...
76 LL | }
77    | - mutable borrow ends here
78
79 error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable
80   --> $DIR/borrowck-borrow-from-owned-ptr.rs:83:18
81    |
82 LL |     let bar1 = &mut foo.bar1.int1;
83    |                     ------------- mutable borrow occurs here
84 LL |     let _foo1 = &foo.bar1; //~ ERROR cannot borrow
85 LL |     let _foo2 = &*foo; //~ ERROR cannot borrow
86    |                  ^^^^ immutable borrow occurs here
87 LL |     *bar1;
88 LL | }
89    | - mutable borrow ends here
90
91 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
92   --> $DIR/borrowck-borrow-from-owned-ptr.rs:90:22
93    |
94 LL |     let bar1 = &mut foo.bar1.int1;
95    |                     ------------- first mutable borrow occurs here
96 LL |     let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
97    |                      ^^^^^^^^ second mutable borrow occurs here
98 LL |     *bar1;
99 LL | }
100    | - first borrow ends here
101
102 error[E0499]: cannot borrow `*foo` as mutable more than once at a time
103   --> $DIR/borrowck-borrow-from-owned-ptr.rs:97:22
104    |
105 LL |     let bar1 = &mut foo.bar1.int1;
106    |                     ------------- first mutable borrow occurs here
107 LL |     let _foo2 = &mut *foo; //~ ERROR cannot borrow
108    |                      ^^^^ second mutable borrow occurs here
109 LL |     *bar1;
110 LL | }
111    | - first borrow ends here
112
113 error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable
114   --> $DIR/borrowck-borrow-from-owned-ptr.rs:104:22
115    |
116 LL |     let bar1 = &foo.bar1.int1;
117    |                 ------------- immutable borrow occurs here
118 LL |     let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
119    |                      ^^^^^^^^ mutable borrow occurs here
120 LL |     *bar1;
121 LL | }
122    | - immutable borrow ends here
123
124 error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable
125   --> $DIR/borrowck-borrow-from-owned-ptr.rs:111:22
126    |
127 LL |     let bar1 = &foo.bar1.int1;
128    |                 ------------- immutable borrow occurs here
129 LL |     let _foo2 = &mut *foo; //~ ERROR cannot borrow
130    |                      ^^^^ mutable borrow occurs here
131 LL |     *bar1;
132 LL | }
133    | - immutable borrow ends here
134
135 error[E0502]: cannot borrow `foo` (via `foo.bar2`) as immutable because `foo` is also borrowed as mutable (via `foo.bar1`)
136   --> $DIR/borrowck-borrow-from-owned-ptr.rs:126:18
137    |
138 LL |     let bar1 = &mut foo.bar1;
139    |                     -------- mutable borrow occurs here (via `foo.bar1`)
140 LL |     let _foo1 = &foo.bar2; //~ ERROR cannot borrow
141    |                  ^^^^^^^^ immutable borrow occurs here (via `foo.bar2`)
142 LL |     *bar1;
143 LL | }
144    | - mutable borrow ends here
145
146 error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable
147   --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:21
148    |
149 LL |     let foo = make_foo();
150    |         --- help: make this binding mutable: `mut foo`
151 LL |     let bar1 = &mut foo.bar1; //~ ERROR cannot borrow
152    |                     ^^^^^^^^ cannot mutably borrow field of immutable binding
153
154 error[E0499]: cannot borrow `foo` (via `foo.bar2.int2`) as mutable more than once at a time
155   --> $DIR/borrowck-borrow-from-owned-ptr.rs:139:21
156    |
157 LL |     let bar1 = &mut foo.bar1.int1;
158    |                     ------------- first mutable borrow occurs here (via `foo.bar1.int1`)
159 LL |     let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow
160    |                     ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2.int2`)
161 ...
162 LL | }
163    | - first borrow ends here
164
165 error: aborting due to 15 previous errors
166
167 Some errors occurred: E0499, E0502, E0596.
168 For more information about an error, try `rustc --explain E0499`.