]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unboxed-closures/issue-30906.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / unboxed-closures / issue-30906.rs
1 #![feature(fn_traits, unboxed_closures)]
2
3 fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}
4
5 struct Compose<F, G>(F, G);
6 impl<T, F, G> FnOnce<(T,)> for Compose<F, G>
7 where
8     F: FnOnce<(T,)>,
9     G: FnOnce<(F::Output,)>,
10 {
11     type Output = G::Output;
12     extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output {
13         (self.1)((self.0)(x))
14     }
15 }
16
17 fn bad<T>(f: fn(&'static str) -> T) {
18     test(Compose(f, |_| {}));
19     //~^ ERROR: implementation of `FnOnce` is not general enough
20 }
21
22 fn main() {}