diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-11-13 00:35:57 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-11-13 00:35:57 +0900 |
| commit | ec45882b42a07303ae3682898124ee8ae035baba (patch) | |
| tree | 4be21d16f2ec943792aa4fe5a1d023d2afdbb448 | |
| parent | e3d998492abd7d61aba12cfa058fce28c998a3ff (diff) | |
| download | rust-ec45882b42a07303ae3682898124ee8ae035baba.tar.gz rust-ec45882b42a07303ae3682898124ee8ae035baba.zip | |
Add test for issue-30904
| -rw-r--r-- | src/test/ui/unboxed-closures/issue-30904.rs | 36 | ||||
| -rw-r--r-- | src/test/ui/unboxed-closures/issue-30904.stderr | 24 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/test/ui/unboxed-closures/issue-30904.rs b/src/test/ui/unboxed-closures/issue-30904.rs new file mode 100644 index 00000000000..eec5e962b43 --- /dev/null +++ b/src/test/ui/unboxed-closures/issue-30904.rs @@ -0,0 +1,36 @@ +#![feature(fn_traits, unboxed_closures)] + +fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {} + +struct Compose<F,G>(F,G); +impl<T,F,G> FnOnce<(T,)> for Compose<F,G> +where F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> { + type Output = G::Output; + extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output { + (self.1)((self.0)(x)) + } +} + +struct Str<'a>(&'a str); +fn mk_str<'a>(s: &'a str) -> Str<'a> { Str(s) } + +fn main() { + let _: for<'a> fn(&'a str) -> Str<'a> = mk_str; + // expected concrete lifetime, found bound lifetime parameter 'a + let _: for<'a> fn(&'a str) -> Str<'a> = Str; + //~^ ERROR: mismatched types + + test(|_: &str| {}); + test(mk_str); + // expected concrete lifetime, found bound lifetime parameter 'x + test(Str); //~ ERROR: type mismatch in function arguments + + test(Compose(|_: &str| {}, |_| {})); + test(Compose(mk_str, |_| {})); + // internal compiler error: cannot relate bound region: + // ReLateBound(DebruijnIndex { depth: 2 }, + // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) + //<= ReSkolemized(0, + // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) + test(Compose(Str, |_| {})); +} diff --git a/src/test/ui/unboxed-closures/issue-30904.stderr b/src/test/ui/unboxed-closures/issue-30904.stderr new file mode 100644 index 00000000000..943cbe0ccc2 --- /dev/null +++ b/src/test/ui/unboxed-closures/issue-30904.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/issue-30904.rs:20:45 + | +LL | let _: for<'a> fn(&'a str) -> Str<'a> = Str; + | ^^^ expected concrete lifetime, found bound lifetime parameter 'a + | + = note: expected type `for<'a> fn(&'a str) -> Str<'a>` + found type `fn(&str) -> Str<'_> {Str::<'_>}` + +error[E0631]: type mismatch in function arguments + --> $DIR/issue-30904.rs:26:10 + | +LL | fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {} + | ---- -------------------------- required by this bound in `test` +... +LL | struct Str<'a>(&'a str); + | ------------------------ found signature of `fn(&str) -> _` +... +LL | test(Str); + | ^^^ expected signature of `for<'x> fn(&'x str) -> _` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. |
