2018-08-12 22:05:29 -05:00
|
|
|
error[E0506]: cannot assign to `i` because it is borrowed
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-block-maybe-bad-lifetime.rs:17:9
|
2018-08-12 22:05:29 -05:00
|
|
|
|
|
|
|
|
LL | &i
|
|
|
|
| -- borrow of `i` occurs here
|
|
|
|
LL | };
|
|
|
|
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
|
|
|
|
| ^^^^^ assignment to borrowed `i` occurs here
|
|
|
|
LL | let _ = i;
|
|
|
|
LL | do_something_with(x);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error[E0382]: borrow of moved value: `x`
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-block-maybe-bad-lifetime.rs:28:24
|
2018-08-12 22:05:29 -05:00
|
|
|
|
|
2019-01-02 18:43:08 -06:00
|
|
|
LL | let x = String::new();
|
|
|
|
| - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
|
|
|
|
...
|
2018-08-12 22:05:29 -05:00
|
|
|
LL | ::std::mem::drop(x);
|
|
|
|
| - value moved here
|
|
|
|
LL | };
|
|
|
|
LL | println!("{}", x); //~ ERROR borrow of moved value: `x`
|
|
|
|
| ^ value borrowed here after move
|
|
|
|
|
|
|
|
error[E0506]: cannot assign to `i` because it is borrowed
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/try-block-maybe-bad-lifetime.rs:40:9
|
2018-08-12 22:05:29 -05:00
|
|
|
|
|
|
|
|
LL | j = &i;
|
|
|
|
| -- borrow of `i` occurs here
|
|
|
|
LL | };
|
|
|
|
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
|
|
|
|
| ^^^^^ assignment to borrowed `i` occurs here
|
|
|
|
LL | let _ = i;
|
|
|
|
LL | do_something_with(j);
|
|
|
|
| - borrow later used here
|
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
|
|
|
|
Some errors occurred: E0382, E0506.
|
|
|
|
For more information about an error, try `rustc --explain E0382`.
|