31 lines
1.3 KiB
Plaintext
31 lines
1.3 KiB
Plaintext
error[E0597]: `factorial` does not live long enough
|
|
--> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15:17
|
|
|
|
|
LL | let f = |x: u32| -> u32 {
|
|
| --------------- capture occurs here
|
|
LL | let g = factorial.as_ref().unwrap();
|
|
| ^^^^^^^^^ borrowed value does not live long enough
|
|
...
|
|
LL | }
|
|
| - borrowed value dropped before borrower
|
|
|
|
|
= note: values in a scope are dropped in the opposite order they are created
|
|
|
|
error[E0373]: closure may outlive the current function, but it borrows `factorial`, which is owned by the current function
|
|
--> $DIR/unboxed-closures-failed-recursive-fn-1.rs:26:13
|
|
|
|
|
LL | let f = |x: u32| -> u32 {
|
|
| ^^^^^^^^^^^^^^^ may outlive borrowed value `factorial`
|
|
LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial`
|
|
LL | let g = factorial.as_ref().unwrap();
|
|
| --------- `factorial` is borrowed here
|
|
help: to force the closure to take ownership of `factorial` (and any other referenced variables), use the `move` keyword
|
|
|
|
|
LL | let f = move |x: u32| -> u32 {
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
Some errors occurred: E0373, E0597.
|
|
For more information about an error, try `rustc --explain E0373`.
|