about summary refs log tree commit diff
path: root/src/test/ui/function-pointer
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-09-28 13:07:20 +0900
committerGitHub <noreply@github.com>2022-09-28 13:07:20 +0900
commitae2028817a9612b47d40093c95d886c2db97a526 (patch)
tree1c8181c7bd48c4acb23d8006c4473aa445523d12 /src/test/ui/function-pointer
parentbf54cfe2b247abe6f3e90d088f72257fb2352d72 (diff)
parente5776c690328a373ec812471f7a257e6c0920881 (diff)
downloadrust-ae2028817a9612b47d40093c95d886c2db97a526.tar.gz
rust-ae2028817a9612b47d40093c95d886c2db97a526.zip
Rollup merge of #102378 - compiler-errors:issue-102289, r=jackh726
Use already resolved `self_ty` in `confirm_fn_pointer_candidate`

Fixes #102289
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() {}