]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr
8cda1e60ba988284ddee1bdca2558c03d0e82da5
[rust.git] / src / test / ui / unboxed-closures / unboxed-closures-failed-recursive-fn-1.nll.stderr
1 error[E0597]: `factorial` does not live long enough
2   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:25:17
3    |
4 LL |     let f = |x: u32| -> u32 {
5    |             --------------- value captured here
6 LL |         let g = factorial.as_ref().unwrap();
7    |                 ^^^^^^^^^ borrowed value does not live long enough
8 ...
9 LL | }
10    | -
11    | |
12    | `factorial` dropped here while still borrowed
13    | borrow later used here, when `factorial` is dropped
14    |
15    = note: values in a scope are dropped in the opposite order they are defined
16
17 error[E0506]: cannot assign to `factorial` because it is borrowed
18   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5
19    |
20 LL |     let f = |x: u32| -> u32 {
21    |             --------------- borrow of `factorial` occurs here
22 LL |         let g = factorial.as_ref().unwrap();
23    |                 --------- borrow occurs due to use in closure
24 ...
25 LL |     factorial = Some(Box::new(f));
26    |     ^^^^^^^^^
27    |     |
28    |     assignment to borrowed `factorial` occurs here
29    |     borrow later used here
30
31 error[E0597]: `factorial` does not live long enough
32   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:38:17
33    |
34 LL |     let f = |x: u32| -> u32 {
35    |             --------------- value captured here
36 LL |         //~^ ERROR closure may outlive the current function, but it borrows `factorial`
37 LL |         let g = factorial.as_ref().unwrap();
38    |                 ^^^^^^^^^ borrowed value does not live long enough
39 ...
40 LL | }
41    | - `factorial` dropped here while still borrowed
42    |
43    = note: borrowed value must be valid for the static lifetime...
44
45 error[E0506]: cannot assign to `factorial` because it is borrowed
46   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:42:5
47    |
48 LL |     let f = |x: u32| -> u32 {
49    |             --------------- borrow of `factorial` occurs here
50 LL |         //~^ ERROR closure may outlive the current function, but it borrows `factorial`
51 LL |         let g = factorial.as_ref().unwrap();
52    |                 --------- borrow occurs due to use in closure
53 ...
54 LL |     factorial = Some(Box::new(f));
55    |     ^^^^^^^^^ assignment to borrowed `factorial` occurs here
56    |
57    = note: borrowed value must be valid for the static lifetime...
58
59 error: aborting due to 4 previous errors
60
61 Some errors occurred: E0506, E0597.
62 For more information about an error, try `rustc --explain E0506`.