Rollup merge of #147597 - JohnTitor:issue-72207, r=chenyukang
Add a regression test for #72207 Closes rust-lang/rust#72207
This commit is contained in:
commit
ae356cb673
1 changed files with 57 additions and 0 deletions
57
tests/ui/impl-trait/associated-type-fn-bound-issue-72207.rs
Normal file
57
tests/ui/impl-trait/associated-type-fn-bound-issue-72207.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
//@ check-pass
|
||||
//@ compile-flags: --crate-type=lib
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub struct XImpl<T, E, F2, F1>
|
||||
where
|
||||
F2: Fn(E),
|
||||
{
|
||||
f1: F1,
|
||||
f2: F2,
|
||||
_ghost: PhantomData<(T, E)>,
|
||||
}
|
||||
|
||||
pub trait X<T>: Sized {
|
||||
type F1;
|
||||
type F2: Fn(Self::E);
|
||||
type E;
|
||||
|
||||
fn and<NewF1, NewF1Generator>(self, f: NewF1Generator) -> XImpl<T, Self::E, Self::F2, NewF1>
|
||||
where
|
||||
NewF1Generator: FnOnce(Self::F1) -> NewF1;
|
||||
}
|
||||
|
||||
impl<T, E, F2, F1> X<T> for XImpl<T, E, F2, F1>
|
||||
where
|
||||
F2: Fn(E),
|
||||
{
|
||||
type E = E;
|
||||
type F2 = F2;
|
||||
type F1 = F1;
|
||||
|
||||
fn and<NewF1, NewF1Generator>(self, f: NewF1Generator) -> XImpl<T, E, F2, NewF1>
|
||||
where
|
||||
NewF1Generator: FnOnce(F1) -> NewF1,
|
||||
{
|
||||
XImpl {
|
||||
f1: f(self.f1),
|
||||
f2: self.f2,
|
||||
_ghost: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn f() -> impl X<(), E = ()> {
|
||||
XImpl {
|
||||
f1: || (),
|
||||
f2: |()| (),
|
||||
_ghost: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
fn f2() -> impl X<(), E = ()> {
|
||||
f().and(|rb| rb)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue