]> git.lizzy.rs Git - rust.git/blob - src/test/ui/static/static-reference-to-fn-2.stderr
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / static / static-reference-to-fn-2.stderr
1 error[E0716]: temporary value dropped while borrowed
2   --> $DIR/static-reference-to-fn-2.rs:18:22
3    |
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
8    |     |                |
9    |     |                creates a temporary which is freed while still in use
10    |     assignment requires that borrow lasts for `'1`
11
12 error[E0716]: temporary value dropped while borrowed
13   --> $DIR/static-reference-to-fn-2.rs:24:22
14    |
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
19    |     |                |
20    |     |                creates a temporary which is freed while still in use
21    |     assignment requires that borrow lasts for `'1`
22
23 error[E0716]: temporary value dropped while borrowed
24   --> $DIR/static-reference-to-fn-2.rs:30:22
25    |
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
30    |     |                |
31    |     |                creates a temporary which is freed while still in use
32    |     assignment requires that borrow lasts for `'1`
33
34 error[E0515]: cannot return value referencing temporary value
35   --> $DIR/static-reference-to-fn-2.rs:40:5
36    |
37 LL | /     StateMachineIter {
38 LL | |
39 LL | |         statefn: &id(state1 as StateMachineFunc)
40    | |                   ------------------------------ temporary value created here
41 LL | |     }
42    | |_____^ returns a value referencing data owned by the current function
43    |
44    = help: use `.collect()` to allocate the iterator
45
46 error: aborting due to 4 previous errors
47
48 Some errors have detailed explanations: E0515, E0716.
49 For more information about an error, try `rustc --explain E0515`.