]> git.lizzy.rs Git - rust.git/blob - tests/ui/try-block/try-block-bad-lifetime.stderr
Rollup merge of #105172 - alexs-sh:issue-98861-fix-next, r=scottmcm
[rust.git] / tests / ui / try-block / try-block-bad-lifetime.stderr
1 error[E0597]: `my_string` does not live long enough
2   --> $DIR/try-block-bad-lifetime.rs:15:33
3    |
4 LL |         let result: Result<(), &str> = try {
5    |             ------ borrow later stored here
6 LL |             let my_string = String::from("");
7 LL |             let my_str: & str = & my_string;
8    |                                 ^^^^^^^^^^^ borrowed value does not live long enough
9 ...
10 LL |         };
11    |         - `my_string` dropped here while still borrowed
12
13 error[E0506]: cannot assign to `i` because it is borrowed
14   --> $DIR/try-block-bad-lifetime.rs:29:13
15    |
16 LL |         let k = &mut i;
17    |                 ------ borrow of `i` occurs here
18 ...
19 LL |             i = 10;
20    |             ^^^^^^ assignment to borrowed `i` occurs here
21 LL |         };
22 LL |         ::std::mem::drop(k);
23    |                          - borrow later used here
24
25 error[E0382]: use of moved value: `k`
26   --> $DIR/try-block-bad-lifetime.rs:31:26
27    |
28 LL |         let k = &mut i;
29    |             - move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait
30 LL |         let mut j: Result<(), &mut i32> = try {
31 LL |             Err(k) ?;
32    |                 - value moved here
33 ...
34 LL |         ::std::mem::drop(k);
35    |                          ^ value used here after move
36
37 error[E0506]: cannot assign to `i` because it is borrowed
38   --> $DIR/try-block-bad-lifetime.rs:32:9
39    |
40 LL |         let k = &mut i;
41    |                 ------ borrow of `i` occurs here
42 ...
43 LL |         i = 40;
44    |         ^^^^^^ assignment to borrowed `i` occurs here
45 LL |
46 LL |         let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") };
47    |                                         - borrow later used here
48
49 error: aborting due to 4 previous errors
50
51 Some errors have detailed explanations: E0382, E0506, E0597.
52 For more information about an error, try `rustc --explain E0382`.