1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// check-pass // compile-flags:-Zpolymorphize=on pub struct OnDrop<F: Fn()>(pub F); impl<F: Fn()> Drop for OnDrop<F> { fn drop(&mut self) { } } fn foo<R, S: FnOnce()>( _: R, _: S, ) { let bar = || { let _ = OnDrop(|| ()); }; bar(); } fn main() { foo(3u32, || {}); }