9 impl Get<usize> for Foo {
10 fn get(self) -> usize {
15 fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
20 //~^ ERROR hidden type for `impl FnOnce()` captures lifetime
25 // After applying suggestion for `foo`:
26 fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
31 //~^ ERROR the parameter type `G` may not live long enough
36 // After applying suggestion for `bar`:
37 fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
38 //~^ ERROR undeclared lifetime name `'a`
47 // After applying suggestion for `baz`:
48 fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
53 //~^ ERROR the parameter type `G` may not live long enough
58 // Same as above, but show that we pay attention to lifetime names from parent item
60 fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
62 //~^ ERROR the parameter type `G` may not live long enough
68 // After applying suggestion for `qux`:
69 fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
74 //~^ ERROR the parameter type `G` may not live long enough
75 //~| ERROR explicit lifetime required
80 // Potential incorrect attempt:
81 fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
86 //~^ ERROR the parameter type `G` may not live long enough
91 // We need to tie the lifetime of `G` with the lifetime of `&mut T` and the returned closure:
92 fn ok<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
101 // This also works. The `'_` isn't necessary but it's where we arrive to following the suggestions:
102 fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a