fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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