|
| 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 F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> { |
| 8 | + type Output = G::Output; |
| 9 | + extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output { |
| 10 | + (self.1)((self.0)(x)) |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +struct Str<'a>(&'a str); |
| 15 | +fn mk_str<'a>(s: &'a str) -> Str<'a> { Str(s) } |
| 16 | + |
| 17 | +fn main() { |
| 18 | + let _: for<'a> fn(&'a str) -> Str<'a> = mk_str; |
| 19 | + // expected concrete lifetime, found bound lifetime parameter 'a |
| 20 | + let _: for<'a> fn(&'a str) -> Str<'a> = Str; |
| 21 | + //~^ ERROR: mismatched types |
| 22 | + |
| 23 | + test(|_: &str| {}); |
| 24 | + test(mk_str); |
| 25 | + // expected concrete lifetime, found bound lifetime parameter 'x |
| 26 | + test(Str); //~ ERROR: type mismatch in function arguments |
| 27 | + |
| 28 | + test(Compose(|_: &str| {}, |_| {})); |
| 29 | + test(Compose(mk_str, |_| {})); |
| 30 | + // internal compiler error: cannot relate bound region: |
| 31 | + // ReLateBound(DebruijnIndex { depth: 2 }, |
| 32 | + // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) |
| 33 | + //<= ReSkolemized(0, |
| 34 | + // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) |
| 35 | + test(Compose(Str, |_| {})); |
| 36 | +} |
0 commit comments