|
| 1 | +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough |
| 2 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9 |
| 3 | + | |
| 4 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 5 | + | ^^^^^^^^ |
| 6 | + | | |
| 7 | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... |
| 8 | + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds |
| 9 | + | |
| 10 | +help: consider adding an explicit lifetime bound |
| 11 | + | |
| 12 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { |
| 13 | + | +++++++++ |
| 14 | + |
| 15 | +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough |
| 16 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9 |
| 17 | + | |
| 18 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 19 | + | ^^^^^^^^ |
| 20 | + | | |
| 21 | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... |
| 22 | + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds |
| 23 | + | |
| 24 | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 25 | +help: consider adding an explicit lifetime bound |
| 26 | + | |
| 27 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { |
| 28 | + | +++++++++ |
| 29 | + |
| 30 | +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough |
| 31 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20 |
| 32 | + | |
| 33 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 34 | + | ^^^^^^^^ |
| 35 | + | | |
| 36 | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... |
| 37 | + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds |
| 38 | + | |
| 39 | +help: consider adding an explicit lifetime bound |
| 40 | + | |
| 41 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { |
| 42 | + | +++++++++ |
| 43 | + |
| 44 | +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough |
| 45 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20 |
| 46 | + | |
| 47 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 48 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 49 | + | | |
| 50 | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... |
| 51 | + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds |
| 52 | + | |
| 53 | +help: consider adding an explicit lifetime bound |
| 54 | + | |
| 55 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { |
| 56 | + | +++++++++ |
| 57 | + |
| 58 | +error[E0310]: the parameter type `I` may not live long enough |
| 59 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 |
| 60 | + | |
| 61 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 62 | + | ^^^^^^^^^^^^^^^^ |
| 63 | + | | |
| 64 | + | the parameter type `I` must be valid for the static lifetime... |
| 65 | + | ...so that the type `I` will meet its required lifetime bounds |
| 66 | + | |
| 67 | +help: consider adding an explicit lifetime bound |
| 68 | + | |
| 69 | +LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { |
| 70 | + | +++++++++ |
| 71 | + |
| 72 | +error[E0310]: the parameter type `I` may not live long enough |
| 73 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 |
| 74 | + | |
| 75 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 76 | + | ^^^^^^^^^^^^^^^^ |
| 77 | + | | |
| 78 | + | the parameter type `I` must be valid for the static lifetime... |
| 79 | + | ...so that the type `I` will meet its required lifetime bounds |
| 80 | + | |
| 81 | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 82 | +help: consider adding an explicit lifetime bound |
| 83 | + | |
| 84 | +LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { |
| 85 | + | +++++++++ |
| 86 | + |
| 87 | +error[E0311]: the parameter type `I` may not live long enough |
| 88 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 |
| 89 | + | |
| 90 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { |
| 91 | + | --------- the parameter type `I` must be valid for the anonymous lifetime defined here... |
| 92 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 93 | + | ^^^^^^^^^^^^^^^^ ...so that the type `I` will meet its required lifetime bounds |
| 94 | + | |
| 95 | +help: consider adding an explicit lifetime bound |
| 96 | + | |
| 97 | +LL | pub fn ack<'a, I: 'a>(&'a mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { |
| 98 | + | +++ ++++ ++ |
| 99 | + |
| 100 | +error[E0597]: `f` does not live long enough |
| 101 | + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:44 |
| 102 | + | |
| 103 | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { |
| 104 | + | - binding `f` declared here |
| 105 | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); |
| 106 | + | -------- ----- ^ borrowed value does not live long enough |
| 107 | + | | | |
| 108 | + | | value captured here |
| 109 | + | coercion requires that `f` is borrowed for `'static` |
| 110 | +... |
| 111 | +LL | } |
| 112 | + | - `f` dropped here while still borrowed |
| 113 | + | |
| 114 | + = 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)>` |
| 115 | + |
| 116 | +error: aborting due to 8 previous errors |
| 117 | + |
| 118 | +Some errors have detailed explanations: E0310, E0311, E0597. |
| 119 | +For more information about an error, try `rustc --explain E0310`. |
0 commit comments