]> git.lizzy.rs Git - rust.git/blob - src/test/ui/cycle-projection-based-on-where-clause.rs
Auto merge of #60132 - davidtwco:issue-60075, r=estebank
[rust.git] / src / test / ui / cycle-projection-based-on-where-clause.rs
1 // Example cycle where a bound on `T` uses a shorthand for `T`. This
2 // creates a cycle because we have to know the bounds on `T` to figure
3 // out what trait defines `Item`, but we can't know the bounds on `T`
4 // without knowing how to handle `T::Item`.
5 //
6 // Note that in the future cases like this could perhaps become legal,
7 // if we got more fine-grained about our cycle detection or changed
8 // how we handle `T::Item` resolution.
9
10 use std::ops::Add;
11
12 // Preamble.
13 trait Trait { type Item; }
14
15 struct A<T>
16     where T : Trait,
17           T : Add<T::Item>
18     //~^ ERROR cycle detected
19     //~| ERROR associated type `Item` not found for `T`
20 {
21     data: T
22 }
23
24 fn main() {
25 }