]>
Commit | Line | Data |
---|---|---|
0731742a | 1 | struct Direct<'a> { |
1a4d82fc | 2 | f: &'a isize |
223e47cc LB |
3 | } |
4 | ||
0731742a | 5 | struct Indirect1 { |
223e47cc | 6 | // Here the lifetime parameter of direct is bound by the fn() |
dc9dc135 | 7 | g: Box<dyn FnOnce(Direct) + 'static> |
223e47cc LB |
8 | } |
9 | ||
0731742a | 10 | struct Indirect2<'a> { |
1a4d82fc | 11 | // But here it is set to 'a |
dc9dc135 | 12 | g: Box<dyn FnOnce(Direct<'a>) + 'static> |
223e47cc LB |
13 | } |
14 | ||
04454e1e | 15 | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } |
923072b8 | 16 | //~^ ERROR lifetime may not live long enough |
1a4d82fc | 17 | |
0731742a | 18 | fn take_indirect1(p: Indirect1) -> Indirect1 { p } |
1a4d82fc | 19 | |
04454e1e | 20 | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } |
923072b8 FG |
21 | //~^ ERROR lifetime may not live long enough |
22 | //~| ERROR lifetime may not live long enough | |
1a4d82fc | 23 | |
223e47cc | 24 | fn main() {} |