summaryrefslogtreecommitdiffstats
path: root/tests/ui/layout/layout-cycle.rs
blob: 85685058e49f55b6c15abacb765061ab6da8a8bb (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
// build-fail
//~^ ERROR: a cycle occurred during layout computation
//~| ERROR: cycle detected when computing layout of

// Issue #111176 -- ensure that we do not emit ICE on layout cycles

use std::mem;

pub struct S<T: Tr> {
    pub f: <T as Tr>::I,
}

pub trait Tr {
    type I: Tr;
}

impl<T: Tr> Tr for S<T> {
    type I = S<S<T>>;
}

impl Tr for () {
    type I = ();
}

fn foo<T: Tr>() -> usize {
    mem::size_of::<S<T>>()
}

fn main() {
    println!("{}", foo::<S<()>>());
}