Skip to content

Commit 7a1a55e

Browse files
authored
Rollup merge of rust-lang#147597 - JohnTitor:issue-72207, r=chenyukang
Add a regression test for rust-lang#72207 Closes rust-lang#72207
2 parents da34d08 + e0b7b23 commit 7a1a55e

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//@ check-pass
2+
//@ compile-flags: --crate-type=lib
3+
4+
#![allow(dead_code)]
5+
6+
use std::marker::PhantomData;
7+
8+
pub struct XImpl<T, E, F2, F1>
9+
where
10+
F2: Fn(E),
11+
{
12+
f1: F1,
13+
f2: F2,
14+
_ghost: PhantomData<(T, E)>,
15+
}
16+
17+
pub trait X<T>: Sized {
18+
type F1;
19+
type F2: Fn(Self::E);
20+
type E;
21+
22+
fn and<NewF1, NewF1Generator>(self, f: NewF1Generator) -> XImpl<T, Self::E, Self::F2, NewF1>
23+
where
24+
NewF1Generator: FnOnce(Self::F1) -> NewF1;
25+
}
26+
27+
impl<T, E, F2, F1> X<T> for XImpl<T, E, F2, F1>
28+
where
29+
F2: Fn(E),
30+
{
31+
type E = E;
32+
type F2 = F2;
33+
type F1 = F1;
34+
35+
fn and<NewF1, NewF1Generator>(self, f: NewF1Generator) -> XImpl<T, E, F2, NewF1>
36+
where
37+
NewF1Generator: FnOnce(F1) -> NewF1,
38+
{
39+
XImpl {
40+
f1: f(self.f1),
41+
f2: self.f2,
42+
_ghost: PhantomData,
43+
}
44+
}
45+
}
46+
47+
fn f() -> impl X<(), E = ()> {
48+
XImpl {
49+
f1: || (),
50+
f2: |()| (),
51+
_ghost: PhantomData,
52+
}
53+
}
54+
55+
fn f2() -> impl X<(), E = ()> {
56+
f().and(|rb| rb)
57+
}

0 commit comments

Comments
 (0)