fork/rust

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

borsAuto merge of #68568 - pietroalbini:stable-next, r=pietroalbini5e1a799842b

1.41.0
1.4 KiB43 linesraw
1error[E0515]: cannot return reference to local variable `x`
2  --> $DIR/polonius-smoke-test.rs:7:5
3   |
4LL |     &x
5   |     ^^ returns a reference to data owned by the current function
6
7error[E0503]: cannot use `x` because it was mutably borrowed
8  --> $DIR/polonius-smoke-test.rs:13:13
9   |
10LL |     let y = &mut x;
11   |             ------ borrow of `x` occurs here
12LL |     let z = x;
13   |             ^ use of borrowed `x`
14LL |     let w = y;
15   |             - borrow later used here
16
17error[E0505]: cannot move out of `x` because it is borrowed
18  --> $DIR/polonius-smoke-test.rs:19:13
19   |
20LL | pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 {
21   |                            - let's call the lifetime of this reference `'1`
22LL |     let y = &mut *x;
23   |             ------- borrow of `*x` occurs here
24LL |     let z = x;
25   |             ^ move out of `x` occurs here
26LL |     y
27   |     - returning this value requires that `*x` is borrowed for `'1`
28
29error[E0505]: cannot move out of `s` because it is borrowed
30  --> $DIR/polonius-smoke-test.rs:43:5
31   |
32LL |     let r = &mut *s;
33   |             ------- borrow of `*s` occurs here
34LL |     let tmp = foo(&r);
35LL |     s;
36   |     ^ move out of `s` occurs here
37LL |     tmp;
38   |     --- borrow later used here
39
40error: aborting due to 4 previous errors
41
42Some errors have detailed explanations: E0503, E0505, E0515.
43For more information about an error, try `rustc --explain E0503`.