]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-consts/associated-const-use-impl-of-same-trait.rs
Rollup merge of #89581 - jblazquez:master, r=Mark-Simulacrum
[rust.git] / src / test / ui / associated-consts / associated-const-use-impl-of-same-trait.rs
1 // run-pass
2
3 // The main purpose of this test is to ensure that different impls of the same
4 // trait can refer to each other without setting off the static recursion check
5 // (as long as there's no actual recursion).
6
7 trait Foo {
8     const BAR: u32;
9 }
10
11 struct IsFoo1;
12
13 impl Foo for IsFoo1 {
14     const BAR: u32 = 1;
15 }
16
17 struct IsFoo2;
18
19 impl Foo for IsFoo2 {
20     const BAR: u32 = <IsFoo1 as Foo>::BAR;
21 }
22
23 fn main() {
24     assert_eq!(<IsFoo1>::BAR, <IsFoo2 as Foo>::BAR);
25 }