1 // Like `projection-bound-cycle.rs` but this avoids using
2 // `feature(trivial_bounds)`.
9 type Item: Sized where <Self as Foo>::Item: Sized;
12 struct Number<T> { t: T }
14 impl<T> Foo for Number<T> {
15 // Well-formedness checks require that the following
18 // if ([T]: Sized) { # if the where clauses hold
19 // [T]: Sized # then the bound on the associated type hold
23 type Item = [T] where [T]: Sized;
24 //~^ ERROR overflow evaluating the requirement `<Number<T> as Foo>::Item == _`
27 struct OnlySized<T> where T: Sized { f: T }
28 impl<T> Print for OnlySized<T> {
30 println!("{}", std::mem::size_of::<T>());
38 impl<T> Bar for T where T: Foo {
39 // This is not ok, we need to prove `wf(<T as Foo>::Item)`, which requires
40 // knowing that `<T as Foo>::Item: Sized` to satisfy the where clause. We
41 // can use the bound on `Foo::Item` for this, but that requires
42 // `wf(<T as Foo>::Item)`, which is an invalid cycle.
43 type Assoc = OnlySized<<T as Foo>::Item>;
47 T::print() // oops, in fact `T = OnlySized<str>` which is ill-formed
51 // we have `FromEnv(T: Bar)` hence
52 // `<T as Bar>::Assoc` is well-formed and
53 // `Implemented(<T as Bar>::Assoc: Print)` hold
54 foo::<<T as Bar>::Assoc>()