about summary refs log tree commit diff
path: root/tests/ui/methods/overflow-if-subtyping.rs
blob: a97f29f1f6dfcae2998578c3ee3ac7c87420ac3c (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
//@ check-pass

// Regression test for #128887.
#![allow(unconditional_recursion)]
trait Mappable<T> {
    type Output;
}

trait Bound<T> {}
// Deleting this impl made it compile on beta
impl<T> Bound<T> for T {}

trait Generic<M> {}

// Deleting the `: Mappable<T>` already made it error on stable.
struct IndexWithIter<I, M: Mappable<T>, T>(I, M, T);

impl<I, M, T> IndexWithIter<I, M, T>
where
    <M as Mappable<T>>::Output: Bound<T>,
    // Flipping these where bounds causes this to succeed, even when removing
    // the where-clause on the struct definition.
    M: Mappable<T>,
    I: Generic<M>,
{
    fn new(x: I) {
        IndexWithIter::<_, _, _>::new(x);
    }
}
fn main() {}