fork/rust

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

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

master
1.6 KiB47 linesraw
1error[E0515]: cannot return reference to local variable `x`
2  --> $DIR/polonius-smoke-test.rs:6: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:12:13
9   |
10LL |     let y = &mut x;
11   |             ------ `x` is borrowed 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:18:13
19   |
20LL | pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 {
21   |                         -  - let's call the lifetime of this reference `'1`
22   |                         |
23   |                         binding `x` declared here
24LL |     let y = &mut *x;
25   |             ------- borrow of `*x` occurs here
26LL |     let z = x;
27   |             ^ move out of `x` occurs here
28LL |     y
29   |     - returning this value requires that `*x` is borrowed for `'1`
30
31error[E0505]: cannot move out of `s` because it is borrowed
32  --> $DIR/polonius-smoke-test.rs:42:5
33   |
34LL |     let s = &mut 1;
35   |         - binding `s` declared here
36LL |     let r = &mut *s;
37   |             ------- borrow of `*s` occurs here
38LL |     let tmp = foo(&r);
39LL |     s;
40   |     ^ move out of `s` occurs here
41LL |     tmp;
42   |     --- borrow later used here
43
44error: aborting due to 4 previous errors
45
46Some errors have detailed explanations: E0503, E0505, E0515.
47For more information about an error, try `rustc --explain E0503`.