]> git.proxmox.com Git - rustc.git/blob - src/test/ui/unboxed-closures/issue-30906.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / unboxed-closures / issue-30906.rs
1 #![feature(fn_traits, unboxed_closures)]
2
3 // revisions: base nll
4 // ignore-compare-mode-nll
5 //[nll] compile-flags: -Z borrowck=mir
6
7 fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}
8
9 struct Compose<F, G>(F, G);
10 impl<T, F, G> FnOnce<(T,)> for Compose<F, G>
11 where
12 F: FnOnce<(T,)>,
13 G: FnOnce<(F::Output,)>,
14 {
15 type Output = G::Output;
16 extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output {
17 (self.1)((self.0)(x))
18 }
19 }
20
21 fn bad<T>(f: fn(&'static str) -> T) {
22 test(Compose(f, |_| {}));
23 //~^ ERROR: implementation of `FnOnce` is not general enough
24 }
25
26 fn main() {}