1
+ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
2
+ --> $DIR/borrowck-reborrow-from-mut.rs:23:17
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
+ | ----- first borrow later used here
10
+
11
+ error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
12
+ --> $DIR/borrowck-reborrow-from-mut.rs:28:17
13
+ |
14
+ LL | let _bar1 = &mut foo.bar1;
15
+ | ------------- mutable borrow occurs here
16
+ LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow
17
+ | ^^^^^^^^^ immutable borrow occurs here
18
+ LL | use_mut(_bar1);
19
+ | ----- mutable borrow later used here
20
+
21
+ error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
22
+ --> $DIR/borrowck-reborrow-from-mut.rs:33:17
23
+ |
24
+ LL | let _bar1 = &foo.bar1;
25
+ | --------- immutable borrow occurs here
26
+ LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
27
+ | ^^^^^^^^^^^^^ mutable borrow occurs here
28
+ LL | use_imm(_bar1);
29
+ | ----- immutable borrow later used here
30
+
31
+ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
32
+ --> $DIR/borrowck-reborrow-from-mut.rs:55:21
33
+ |
34
+ LL | let _bar1 = &mut foo.bar1;
35
+ | ------------- first mutable borrow occurs here
36
+ LL | match *foo {
37
+ LL | Foo { bar1: ref mut _bar1, bar2: _ } => {}
38
+ | ^^^^^^^^^^^^^ second mutable borrow occurs here
39
+ ...
40
+ LL | use_mut(_bar1);
41
+ | ----- first borrow later used here
42
+
43
+ error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
44
+ --> $DIR/borrowck-reborrow-from-mut.rs:62:17
45
+ |
46
+ LL | let _bar1 = &mut foo.bar1.int1;
47
+ | ------------------ mutable borrow occurs here
48
+ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
49
+ | ^^^^^^^^^ immutable borrow occurs here
50
+ LL | let _foo2 = &*foo; //~ ERROR cannot borrow
51
+ LL | use_mut(_bar1);
52
+ | ----- mutable borrow later used here
53
+
54
+ error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable
55
+ --> $DIR/borrowck-reborrow-from-mut.rs:63:17
56
+ |
57
+ LL | let _bar1 = &mut foo.bar1.int1;
58
+ | ------------------ mutable borrow occurs here
59
+ LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
60
+ LL | let _foo2 = &*foo; //~ ERROR cannot borrow
61
+ | ^^^^^ immutable borrow occurs here
62
+ LL | use_mut(_bar1);
63
+ | ----- mutable borrow later used here
64
+
65
+ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
66
+ --> $DIR/borrowck-reborrow-from-mut.rs:68:17
67
+ |
68
+ LL | let _bar1 = &mut foo.bar1.int1;
69
+ | ------------------ first mutable borrow occurs here
70
+ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
71
+ | ^^^^^^^^^^^^^ second mutable borrow occurs here
72
+ LL | use_mut(_bar1);
73
+ | ----- first borrow later used here
74
+
75
+ error[E0499]: cannot borrow `*foo` as mutable more than once at a time
76
+ --> $DIR/borrowck-reborrow-from-mut.rs:73:17
77
+ |
78
+ LL | let _bar1 = &mut foo.bar1.int1;
79
+ | ------------------ first mutable borrow occurs here
80
+ LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
81
+ | ^^^^^^^^^ second mutable borrow occurs here
82
+ LL | use_mut(_bar1);
83
+ | ----- first borrow later used here
84
+
85
+ error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
86
+ --> $DIR/borrowck-reborrow-from-mut.rs:78:17
87
+ |
88
+ LL | let _bar1 = &foo.bar1.int1;
89
+ | -------------- immutable borrow occurs here
90
+ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
91
+ | ^^^^^^^^^^^^^ mutable borrow occurs here
92
+ LL | use_imm(_bar1);
93
+ | ----- immutable borrow later used here
94
+
95
+ error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable
96
+ --> $DIR/borrowck-reborrow-from-mut.rs:83:17
97
+ |
98
+ LL | let _bar1 = &foo.bar1.int1;
99
+ | -------------- immutable borrow occurs here
100
+ LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
101
+ | ^^^^^^^^^ mutable borrow occurs here
102
+ LL | use_imm(_bar1);
103
+ | ----- immutable borrow later used here
104
+
1
105
error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference
2
106
--> $DIR/borrowck-reborrow-from-mut.rs:98:17
3
107
|
@@ -6,6 +110,7 @@ LL | fn borrow_mut_from_imm(foo: &Foo) {
6
110
LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow
7
111
| ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable
8
112
9
- error: aborting due to previous error
113
+ error: aborting due to 11 previous errors
10
114
11
- For more information about this error, try `rustc --explain E0596`.
115
+ Some errors occurred: E0499, E0502, E0596.
116
+ For more information about an error, try `rustc --explain E0499`.
0 commit comments