about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/impl-trait/nested-hkl-lifetime.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/nested-hkl-lifetime.rs b/tests/ui/impl-trait/nested-hkl-lifetime.rs
new file mode 100644
index 00000000000..089ceca6777
--- /dev/null
+++ b/tests/ui/impl-trait/nested-hkl-lifetime.rs
@@ -0,0 +1,32 @@
+//@ check-pass
+
+use std::iter::FromIterator;
+
+struct DynamicAlt<P>(P);
+
+impl<P> FromIterator<P> for DynamicAlt<P> {
+    fn from_iter<T: IntoIterator<Item = P>>(_iter: T) -> Self {
+        loop {}
+    }
+}
+
+fn owned_context<I, F>(_: F) -> impl FnMut(I) -> I {
+    |i| i
+}
+
+trait Parser<I> {}
+
+impl<T, I> Parser<I> for T where T: FnMut(I) -> I {}
+
+fn alt<I, P: Parser<I>>(_: DynamicAlt<P>) -> impl FnMut(I) -> I {
+    |i| i
+}
+
+fn rule_to_parser<'c>() -> impl Parser<&'c str> {
+    move |input| {
+        let v: Vec<()> = vec![];
+        alt(v.iter().map(|()| owned_context(rule_to_parser())).collect::<DynamicAlt<_>>())(input)
+    }
+}
+
+fn main() {}