2020-06-22 07:57:03 -05:00
|
|
|
// check-pass
|
2020-07-22 09:03:56 -05:00
|
|
|
// compile-flags:-Zpolymorphize=on
|
2020-06-22 07:57:03 -05:00
|
|
|
|
|
|
|
pub struct OnDrop<F: Fn()>(pub F);
|
|
|
|
|
|
|
|
impl<F: Fn()> Drop for OnDrop<F> {
|
|
|
|
fn drop(&mut self) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bar<F: FnOnce()>(f: F) {
|
|
|
|
let _ = OnDrop(|| ());
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo<R, S: FnOnce()>(
|
|
|
|
_: R,
|
|
|
|
_: S,
|
|
|
|
) {
|
|
|
|
let bar = || {
|
|
|
|
bar(|| {})
|
|
|
|
};
|
|
|
|
let _ = bar();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo(3u32, || {});
|
|
|
|
}
|