]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/associated-const-use-impl-of-same-trait.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / test / run-pass / associated-const-use-impl-of-same-trait.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
12 // The main purpose of this test is to ensure that different impls of the same
13 // trait can refer to each other without setting off the static recursion check
14 // (as long as there's no actual recursion).
15
16 trait Foo {
17 const BAR: u32;
18 }
19
20 struct IsFoo1;
21
22 impl Foo for IsFoo1 {
23 const BAR: u32 = 1;
24 }
25
26 struct IsFoo2;
27
28 impl Foo for IsFoo2 {
29 const BAR: u32 = <IsFoo1 as Foo>::BAR;
30 }
31
32 fn main() {
33 assert_eq!(<IsFoo1>::BAR, <IsFoo2 as Foo>::BAR);
34 }