File: try-block-maybe-bad-lifetime.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (46 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
error[E0506]: cannot assign to `i` because it is borrowed
  --> $DIR/try-block-maybe-bad-lifetime.rs:17:9
   |
LL |             &i
   |             -- `i` is borrowed here
LL |         };
LL |         i = 0;
   |         ^^^^^ `i` is assigned to here but it was already borrowed
LL |         let _ = i;
LL |         do_something_with(x);
   |                           - borrow later used here

error[E0382]: borrow of moved value: `x`
  --> $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 |         };
LL |         println!("{}", x);
   |                        ^ value borrowed here after move
   |
   = 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
  --> $DIR/try-block-maybe-bad-lifetime.rs:40:9
   |
LL |             j = &i;
   |                 -- `i` is borrowed here
LL |         };
LL |         i = 0;
   |         ^^^^^ `i` is assigned to here but it was already borrowed
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`.