|
1 | | -error: compilation successful |
2 | | - --> $DIR/borrowck-report-with-custom-diagnostic.rs:12:1 |
| 1 | +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable |
| 2 | + --> $DIR/borrowck-report-with-custom-diagnostic.rs:17:13 |
3 | 3 | | |
4 | | -LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 |
5 | | -LL | | // Original borrow ends at end of function |
6 | | -LL | | let mut x = 1; |
7 | | -LL | | let y = &mut x; |
8 | | -... | |
9 | | -LL | | //~^ immutable borrow occurs here |
10 | | -LL | | } |
11 | | - | |_^ |
| 4 | +LL | let y = &mut x; |
| 5 | + | ------ mutable borrow occurs here |
| 6 | +LL | //~^ mutable borrow occurs here |
| 7 | +LL | let z = &x; //~ ERROR cannot borrow |
| 8 | + | ^^ immutable borrow occurs here |
| 9 | +... |
| 10 | +LL | y.use_mut(); |
| 11 | + | - borrow later used here |
12 | 12 |
|
13 | | -error: aborting due to previous error |
| 13 | +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable |
| 14 | + --> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21 |
| 15 | + | |
| 16 | +LL | let y = &x; |
| 17 | + | -- immutable borrow occurs here |
| 18 | +LL | //~^ immutable borrow occurs here |
| 19 | +LL | let z = &mut x; //~ ERROR cannot borrow |
| 20 | + | ^^^^^^ mutable borrow occurs here |
| 21 | +... |
| 22 | +LL | y.use_ref(); |
| 23 | + | - borrow later used here |
| 24 | + |
| 25 | +error[E0499]: cannot borrow `x` as mutable more than once at a time |
| 26 | + --> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17 |
| 27 | + | |
| 28 | +LL | let y = &mut x; |
| 29 | + | ------ first mutable borrow occurs here |
| 30 | +LL | //~^ first mutable borrow occurs here |
| 31 | +LL | let z = &mut x; //~ ERROR cannot borrow |
| 32 | + | ^^^^^^ second mutable borrow occurs here |
| 33 | +... |
| 34 | +LL | y.use_mut(); |
| 35 | + | - borrow later used here |
| 36 | + |
| 37 | +error: aborting due to 3 previous errors |
14 | 38 |
|
| 39 | +Some errors occurred: E0499, E0502. |
| 40 | +For more information about an error, try `rustc --explain E0499`. |
0 commit comments