]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr
Auto merge of #105650 - cassaundra:float-literal-suggestion, r=pnkfelix
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-failed-recursive-fn-1.stderr
1 error[E0597]: `factorial` does not live long enough
2   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15: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 might be used here, when `factorial` is dropped and runs the destructor for type `Option<Box<dyn Fn(u32) -> u32>>`
14
15 error[E0506]: cannot assign to `factorial` because it is borrowed
16   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5
17    |
18 LL |     let f = |x: u32| -> u32 {
19    |             --------------- `factorial` is borrowed here
20 LL |         let g = factorial.as_ref().unwrap();
21    |                 --------- borrow occurs due to use in closure
22 ...
23 LL |     factorial = Some(Box::new(f));
24    |     ^^^^^^^^^
25    |     |
26    |     `factorial` is assigned to here but it was already borrowed
27    |     borrow later used here
28
29 error[E0597]: `factorial` does not live long enough
30   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17
31    |
32 LL |     let mut factorial: Option<Box<dyn Fn(u32) -> u32 + 'static>> = None;
33    |                        ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static`
34 LL |
35 LL |     let f = |x: u32| -> u32 {
36    |             --------------- value captured here
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 error[E0506]: cannot assign to `factorial` because it is borrowed
44   --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:33:5
45    |
46 LL |     let mut factorial: Option<Box<dyn Fn(u32) -> u32 + 'static>> = None;
47    |                        ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static`
48 LL |
49 LL |     let f = |x: u32| -> u32 {
50    |             --------------- `factorial` is borrowed here
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    |     ^^^^^^^^^ `factorial` is assigned to here but it was already borrowed
56
57 error: aborting due to 4 previous errors
58
59 Some errors have detailed explanations: E0506, E0597.
60 For more information about an error, try `rustc --explain E0506`.