about summary refs log tree commit diff
path: root/tests/ui/borrowck/unconstrained-closure-lifetime-generic.stderr
blob: df86ce79f09c7e7940e72873607040d5c7df085e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |         ^^^^^^^^
   |         |
   |         the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
   |         ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
   |                                                                      +++++++++

error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |         ^^^^^^^^
   |         |
   |         the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
   |         ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
   |                                                                      +++++++++

error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |                    ^^^^^^^^
   |                    |
   |                    the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
   |                    ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
   |                                                                      +++++++++

error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                    |
   |                    the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
   |                    ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
   |                                                                      +++++++++

error[E0310]: the parameter type `I` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |                                   ^^^^^^^^^^^^^^^^
   |                                   |
   |                                   the parameter type `I` must be valid for the static lifetime...
   |                                   ...so that the type `I` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
   |                 +++++++++

error[E0310]: the parameter type `I` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
   |
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |                                   ^^^^^^^^^^^^^^^^
   |                                   |
   |                                   the parameter type `I` must be valid for the static lifetime...
   |                                   ...so that the type `I` will meet its required lifetime bounds
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
   |                 +++++++++

error[E0311]: the parameter type `I` may not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
   |                   --------- the parameter type `I` must be valid for the anonymous lifetime defined here...
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |                                   ^^^^^^^^^^^^^^^^ ...so that the type `I` will meet its required lifetime bounds
   |
help: consider adding an explicit lifetime bound
   |
LL |     pub fn ack<'a, I: 'a>(&'a mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
   |                +++  ++++   ++

error[E0597]: `f` does not live long enough
  --> $DIR/unconstrained-closure-lifetime-generic.rs:10:44
   |
LL |     pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
   |                              - binding `f` declared here
LL |         self.bar = Box::new(|baz| Box::new(f(baz)));
   |         --------            -----          ^ borrowed value does not live long enough
   |         |                   |
   |         |                   value captured here
   |         coercion requires that `f` is borrowed for `'static`
...
LL |     }
   |     - `f` dropped here while still borrowed
   |
   = note: due to object lifetime defaults, `Box<dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)>>` actually means `Box<(dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)> + 'static)>`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0310, E0311, E0597.
For more information about an error, try `rustc --explain E0310`.