about summary refs log tree commit diff
path: root/src/test/ui/function-pointer
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-21 10:21:17 +0000
committerbors <bors@rust-lang.org>2022-10-21 10:21:17 +0000
commitbefc94e691ae36c2fad134e1cdf483b7bdeeb74f (patch)
tree295eb20dddee89560f4e67c9fc14937611688207 /src/test/ui/function-pointer
parent53e357748675b387b6d25fe563b960cb7a7a0aea (diff)
parentbb911ce32aeef2d691af993d0a1696d8402998a9 (diff)
downloadrust-befc94e691ae36c2fad134e1cdf483b7bdeeb74f.tar.gz
rust-befc94e691ae36c2fad134e1cdf483b7bdeeb74f.zip
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'src/test/ui/function-pointer')
-rw-r--r--src/test/ui/function-pointer/issue-102289.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/ui/function-pointer/issue-102289.rs b/src/test/ui/function-pointer/issue-102289.rs
new file mode 100644
index 00000000000..de394ca9ad6
--- /dev/null
+++ b/src/test/ui/function-pointer/issue-102289.rs
@@ -0,0 +1,54 @@
+// check-pass
+
+pub(crate) trait Parser: Sized {
+    type Output;
+    fn parse(&mut self, _input: &str) -> Result<(), ()> {
+        loop {}
+    }
+    fn map<F, B>(self, _f: F) -> Map<Self, F>
+    where
+        F: FnMut(Self::Output) -> B,
+    {
+        todo!()
+    }
+}
+
+pub(crate) struct Chainl1<P, Op>(P, Op);
+impl<P, Op> Parser for Chainl1<P, Op>
+where
+    P: Parser,
+    Op: Parser,
+    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
+{
+    type Output = P::Output;
+}
+pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
+where
+    P: Parser,
+    Op: Parser,
+    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
+{
+    loop {}
+}
+
+pub(crate) struct Map<P, F>(P, F);
+impl<A, B, P, F> Parser for Map<P, F>
+where
+    P: Parser<Output = A>,
+    F: FnMut(A) -> B,
+{
+    type Output = B;
+}
+
+impl Parser for u32 {
+    type Output = ();
+}
+
+pub fn chainl1_error_consume() {
+    fn first<T, U>(t: T, _: U) -> T {
+        t
+    }
+    let _ = chainl1(1, 1.map(|_| first)).parse("");
+}
+
+fn main() {}