]> git.lizzy.rs Git - rust.git/blob - src/test/ui/cycle-projection-based-on-where-clause.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / cycle-projection-based-on-where-clause.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Example cycle where a bound on `T` uses a shorthand for `T`. This
12 // creates a cycle because we have to know the bounds on `T` to figure
13 // out what trait defines `Item`, but we can't know the bounds on `T`
14 // without knowing how to handle `T::Item`.
15 //
16 // Note that in the future cases like this could perhaps become legal,
17 // if we got more fine-grained about our cycle detection or changed
18 // how we handle `T::Item` resolution.
19
20 use std::ops::Add;
21
22 // Preamble.
23 trait Trait { type Item; }
24
25 struct A<T>
26     where T : Trait,
27           T : Add<T::Item>
28     //~^ ERROR cycle detected
29     //~| ERROR associated type `Item` not found for `T`
30 {
31     data: T
32 }
33
34 fn main() {
35 }