rust/tests/ui/try-block/try-block-maybe-bad-lifetime.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.7 KiB
Plaintext
Raw Normal View History

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
|
LL | &i
| -- borrow of `i` occurs here
LL | };
2019-03-09 06:03:44 -06:00
LL | i = 0;
| ^^^^^ 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
|
LL | let x = String::new();
| - move occurs because `x` has type `String`, which does not implement the `Copy` trait
...
LL | ::std::mem::drop(x);
| - value moved here
LL | };
2019-03-09 06:03:44 -06:00
LL | println!("{}", x);
| ^ value borrowed here after move
2021-10-21 09:01:16 -05: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)
help: consider cloning the value if the performance cost is acceptable
|
LL | ::std::mem::drop(x.clone());
| ++++++++
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
|
LL | j = &i;
| -- borrow of `i` occurs here
LL | };
2019-03-09 06:03:44 -06:00
LL | i = 0;
| ^^^^^ 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 have detailed explanations: E0382, E0506.
For more information about an error, try `rustc --explain E0382`.