]> git.proxmox.com Git - rustc.git/blame - tests/ui/try-block/try-block-maybe-bad-lifetime.stderr
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / try-block / try-block-maybe-bad-lifetime.stderr
CommitLineData
b7449926 1error[E0506]: cannot assign to `i` because it is borrowed
0731742a 2 --> $DIR/try-block-maybe-bad-lifetime.rs:17:9
b7449926
XL
3 |
4LL | &i
5 | -- borrow of `i` occurs here
6LL | };
532ac7d7 7LL | i = 0;
b7449926
XL
8 | ^^^^^ assignment to borrowed `i` occurs here
9LL | let _ = i;
10LL | do_something_with(x);
11 | - borrow later used here
12
13error[E0382]: borrow of moved value: `x`
0731742a 14 --> $DIR/try-block-maybe-bad-lifetime.rs:28:24
b7449926 15 |
9fa01778 16LL | let x = String::new();
1b1a35ee 17 | - move occurs because `x` has type `String`, which does not implement the `Copy` trait
9fa01778 18...
b7449926
XL
19LL | ::std::mem::drop(x);
20 | - value moved here
21LL | };
532ac7d7 22LL | println!("{}", x);
b7449926 23 | ^ value borrowed here after move
a2a8927a 24 |
064997fb 25 = 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)
6522a427
EL
26help: consider cloning the value if the performance cost is acceptable
27 |
28LL | ::std::mem::drop(x.clone());
29 | ++++++++
b7449926
XL
30
31error[E0506]: cannot assign to `i` because it is borrowed
0731742a 32 --> $DIR/try-block-maybe-bad-lifetime.rs:40:9
b7449926
XL
33 |
34LL | j = &i;
35 | -- borrow of `i` occurs here
36LL | };
532ac7d7 37LL | i = 0;
b7449926
XL
38 | ^^^^^ assignment to borrowed `i` occurs here
39LL | let _ = i;
40LL | do_something_with(j);
41 | - borrow later used here
42
43error: aborting due to 3 previous errors
44
48663c56 45Some errors have detailed explanations: E0382, E0506.
b7449926 46For more information about an error, try `rustc --explain E0382`.