summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/issue-43132.rs
blob: c886f4b0a2d6bdadd801bc16f3396a4a8717422b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// run-pass
#![allow(unused)]

fn main() {
}

fn foo() {
    let b = mk::<
        Forward<(Box<dyn Future<Error = u32>>,)>,
    >();
    b.map_err(|_| ()).join();
}

fn mk<T>() -> T {
    loop {}
}

impl<I: Future<Error = E>, E> Future for (I,) {
    type Error = E;
}

struct Forward<T: Future> {
    _a: T,
}

impl<T: Future> Future for Forward<T>
where
    T::Error: From<u32>,
{
    type Error = T::Error;
}

trait Future {
    type Error;

    fn map_err<F, E>(self, _: F) -> (Self, F)
    where
        F: FnOnce(Self::Error) -> E,
        Self: Sized,
    {
        loop {}
    }

    fn join(self) -> (MaybeDone<Self>, ())
    where
        Self: Sized,
    {
        loop {}
    }
}

impl<S: ?Sized + Future> Future for Box<S> {
    type Error = S::Error;
}

enum MaybeDone<A: Future> {
    _Done(A::Error),
}

impl<U, A: Future, F> Future for (A, F)
where
    F: FnOnce(A::Error) -> U,
{
    type Error = U;
}