fork/rust

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

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

master
2.3 KiB49 linesraw
1error[E0716]: temporary value dropped while borrowed
2  --> $DIR/static-reference-to-fn-2.rs:18:22
3   |
4LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> {
5   |           ----- has type `&mut StateMachineIter<'1>`
6LL |     self_.statefn = &id(state2 as StateMachineFunc);
7   |     -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
8   |     |                |
9   |     |                creates a temporary value which is freed while still in use
10   |     assignment requires that borrow lasts for `'1`
11
12error[E0716]: temporary value dropped while borrowed
13  --> $DIR/static-reference-to-fn-2.rs:24:22
14   |
15LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> {
16   |           ----- has type `&mut StateMachineIter<'1>`
17LL |     self_.statefn = &id(state3 as StateMachineFunc);
18   |     -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
19   |     |                |
20   |     |                creates a temporary value which is freed while still in use
21   |     assignment requires that borrow lasts for `'1`
22
23error[E0716]: temporary value dropped while borrowed
24  --> $DIR/static-reference-to-fn-2.rs:30:22
25   |
26LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> {
27   |           ----- has type `&mut StateMachineIter<'1>`
28LL |     self_.statefn = &id(finished as StateMachineFunc);
29   |     -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
30   |     |                |
31   |     |                creates a temporary value which is freed while still in use
32   |     assignment requires that borrow lasts for `'1`
33
34error[E0515]: cannot return value referencing temporary value
35  --> $DIR/static-reference-to-fn-2.rs:40:5
36   |
37LL | /     StateMachineIter {
38LL | |
39LL | |         statefn: &id(state1 as StateMachineFunc)
40   | |                   ------------------------------ temporary value created here
41LL | |     }
42   | |_____^ returns a value referencing data owned by the current function
43   |
44   = help: use `.collect()` to allocate the iterator
45
46error: aborting due to 4 previous errors
47
48Some errors have detailed explanations: E0515, E0716.
49For more information about an error, try `rustc --explain E0515`.