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;
26 struct OnlySized<T> where T: Sized { f: T }
27 impl<T> Print for OnlySized<T> {
29 println!("{}", std::mem::size_of::<T>());
37 impl<T> Bar for T where T: Foo {
38 // This is not ok, we need to prove `wf(<T as Foo>::Item)`, which requires
39 // knowing that `<T as Foo>::Item: Sized` to satisfy the where clause. We
40 // can use the bound on `Foo::Item` for this, but that requires
41 // `wf(<T as Foo>::Item)`, which is an invalid cycle.
42 type Assoc = OnlySized<<T as Foo>::Item>;
43 //~^ ERROR overflow evaluating the requirement `<T as Foo>::Item: Sized`
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>()