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-09-28 04:18:19 +0000
committerbors <bors@rust-lang.org>2022-09-28 04:18:19 +0000
commit837bf370de144a682041e68bb67469b9f68a55ce (patch)
treead6fb53f2919d4c12d206c01acf057104ff212aa /src/test/ui/function-pointer
parentd6734be398fde0b078cde298e0d84eeccd71d08e (diff)
parentce15514df969522d507c6ab63f7472dc2c45d86c (diff)
downloadrust-837bf370de144a682041e68bb67469b9f68a55ce.tar.gz
rust-837bf370de144a682041e68bb67469b9f68a55ce.zip
Auto merge of #102388 - JohnTitor:rollup-mbyw6fl, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #100747 (Add long description and test for E0311)
 - #102232 (Stabilize bench_black_box)
 - #102288 (Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.)
 - #102338 (Deny associated type bindings within associated type bindings)
 - #102347 (Unescaping cleanups)
 - #102348 (Tweak `FulfillProcessor`.)
 - #102378 (Use already resolved `self_ty` in `confirm_fn_pointer_candidate`)
 - #102380 (rustdoc: remove redundant mobile `.source > .sidebar` CSS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
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() {}