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