]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / borrowck / borrowck-reborrow-from-mut.stderr
1 error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
2   --> $DIR/borrowck-reborrow-from-mut.rs:13: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 |     use_mut(_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-reborrow-from-mut.rs:18: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 |     use_mut(_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-reborrow-from-mut.rs:23: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 |     use_imm(_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-reborrow-from-mut.rs:45: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-reborrow-from-mut.rs:52: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-reborrow-from-mut.rs:53: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 |     use_mut(_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-reborrow-from-mut.rs:58: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 |     use_mut(_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-reborrow-from-mut.rs:63: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 |     use_mut(_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-reborrow-from-mut.rs:68: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 |     use_imm(_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-reborrow-from-mut.rs:73: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 |     use_imm(_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-reborrow-from-mut.rs:88:22
115    |
116 LL | fn borrow_mut_from_imm(foo: &Foo) {
117    |                             ---- use `&mut Foo` here to make mutable
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`.