summaryrefslogtreecommitdiffstats
path: root/tests/ui/try-block/try-block-bad-lifetime.stderr
blob: 28941cb0a9e4033296ed05666e0a03684d30630b (plain)
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
47
48
49
50
51
52
53
error[E0597]: `my_string` does not live long enough
  --> $DIR/try-block-bad-lifetime.rs:15:33
   |
LL |         let result: Result<(), &str> = try {
   |             ------ borrow later stored here
LL |             let my_string = String::from("");
   |                 --------- binding `my_string` declared here
LL |             let my_str: & str = & my_string;
   |                                 ^^^^^^^^^^^ borrowed value does not live long enough
...
LL |         };
   |         - `my_string` dropped here while still borrowed

error[E0506]: cannot assign to `i` because it is borrowed
  --> $DIR/try-block-bad-lifetime.rs:29:13
   |
LL |         let k = &mut i;
   |                 ------ `i` is borrowed here
...
LL |             i = 10;
   |             ^^^^^^ `i` is assigned to here but it was already borrowed
LL |         };
LL |         ::std::mem::drop(k);
   |                          - borrow later used here

error[E0382]: use of moved value: `k`
  --> $DIR/try-block-bad-lifetime.rs:31:26
   |
LL |         let k = &mut i;
   |             - move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait
LL |         let mut j: Result<(), &mut i32> = try {
LL |             Err(k) ?;
   |                 - value moved here
...
LL |         ::std::mem::drop(k);
   |                          ^ value used here after move

error[E0506]: cannot assign to `i` because it is borrowed
  --> $DIR/try-block-bad-lifetime.rs:32:9
   |
LL |         let k = &mut i;
   |                 ------ `i` is borrowed here
...
LL |         i = 40;
   |         ^^^^^^ `i` is assigned to here but it was already borrowed
LL |
LL |         let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") };
   |                                         - borrow later used here

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0382, E0506, E0597.
For more information about an error, try `rustc --explain E0382`.