fork/rust

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

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

master
2.2 KiB60 linesraw
1error[E0382]: use of moved value
2  --> $DIR/issue-83760.rs:5:20
3   |
4LL |     while let Some(foo) = val {
5   |                    ^^^ value moved here, in previous iteration of loop
6LL |         if true {
7LL |             val = None;
8   |             ---------- this reinitialization might get skipped
9   |
10   = note: move occurs because value has type `Struct`, which does not implement the `Copy` trait
11help: borrow this binding in the pattern to avoid moving the value
12   |
13LL |     while let Some(ref foo) = val {
14   |                    +++
15
16error[E0382]: use of moved value: `foo`
17  --> $DIR/issue-83760.rs:21:14
18   |
19LL |     let mut foo = Some(Struct);
20   |         ------- move occurs because `foo` has type `Option<Struct>`, which does not implement the `Copy` trait
21LL |     let _x = foo.unwrap();
22   |                  -------- `foo` moved due to this method call
23LL |     if true {
24LL |         foo = Some(Struct);
25   |         ------------------ this reinitialization might get skipped
26...
27LL |     let _y = foo;
28   |              ^^^ value used here after move
29   |
30note: `Option::<T>::unwrap` takes ownership of the receiver `self`, which moves `foo`
31  --> $SRC_DIR/core/src/option.rs:LL:COL
32
33error[E0382]: use of moved value: `foo`
34  --> $DIR/issue-83760.rs:37:14
35   |
36LL |     let mut foo = Some(Struct);
37   |         ------- move occurs because `foo` has type `Option<Struct>`, which does not implement the `Copy` trait
38LL |     let _x = foo.unwrap();
39   |                  -------- `foo` moved due to this method call
40...
41LL |     let _y = foo;
42   |              ^^^ value used here after move
43   |
44note: these 3 reinitializations and 1 other might get skipped
45  --> $DIR/issue-83760.rs:30:9
46   |
47LL |         foo = Some(Struct);
48   |         ^^^^^^^^^^^^^^^^^^
49LL |     } else if true {
50LL |         foo = Some(Struct);
51   |         ^^^^^^^^^^^^^^^^^^
52LL |     } else if true {
53LL |         foo = Some(Struct);
54   |         ^^^^^^^^^^^^^^^^^^
55note: `Option::<T>::unwrap` takes ownership of the receiver `self`, which moves `foo`
56  --> $SRC_DIR/core/src/option.rs:LL:COL
57
58error: aborting due to 3 previous errors
59
60For more information about this error, try `rustc --explain E0382`.