2018-08-13 03:05:29 +00:00
error[E0506]: cannot assign to `i` because it is borrowed
2018-12-25 15:56:47 +00:00
--> $DIR/try-block-maybe-bad-lifetime.rs:17:9
2018-08-13 03:05:29 +00:00
|
LL | &i
2023-01-15 03:06:44 +00:00
| -- `i` is borrowed here
2018-08-13 03:05:29 +00:00
LL | };
2019-03-09 12:03:44 +00:00
LL | i = 0;
2023-01-15 03:06:44 +00:00
| ^^^^^ `i` is assigned to here but it was already borrowed
2018-08-13 03:05:29 +00:00
LL | let _ = i;
LL | do_something_with(x);
| - borrow later used here
error[E0382]: borrow of moved value: `x`
2018-12-25 15:56:47 +00:00
--> $DIR/try-block-maybe-bad-lifetime.rs:28:24
2018-08-13 03:05:29 +00:00
|
2019-01-03 00:43:08 +00:00
LL | let x = String::new();
2020-09-02 07:40:56 +00:00
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
2019-01-03 00:43:08 +00:00
...
2018-08-13 03:05:29 +00:00
LL | ::std::mem::drop(x);
| - value moved here
LL | };
2019-03-09 12:03:44 +00:00
LL | println!("{}", x);
2018-08-13 03:05:29 +00:00
| ^ value borrowed here after move
2021-10-21 14:01:16 +00:00
|
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
2022-11-03 04:22:24 +00:00
help: consider cloning the value if the performance cost is acceptable
|
LL | ::std::mem::drop(x.clone());
| ++++++++
2018-08-13 03:05:29 +00:00
error[E0506]: cannot assign to `i` because it is borrowed
2018-12-25 15:56:47 +00:00
--> $DIR/try-block-maybe-bad-lifetime.rs:40:9
2018-08-13 03:05:29 +00:00
|
LL | j = &i;
2023-01-15 03:06:44 +00:00
| -- `i` is borrowed here
2018-08-13 03:05:29 +00:00
LL | };
2019-03-09 12:03:44 +00:00
LL | i = 0;
2023-01-15 03:06:44 +00:00
| ^^^^^ `i` is assigned to here but it was already borrowed
2018-08-13 03:05:29 +00:00
LL | let _ = i;
LL | do_something_with(j);
| - borrow later used here
error: aborting due to 3 previous errors
2019-04-17 17:26:38 +00:00
Some errors have detailed explanations: E0382, E0506.
2018-08-13 03:05:29 +00:00
For more information about an error, try `rustc --explain E0382`.