]> git.proxmox.com Git - rustc.git/blame - 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
CommitLineData
1a4d82fc 1// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
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
85aaf69f 11
d9579d0f
AL
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
16trait Foo {
17 const BAR: u32;
18}
19
20struct IsFoo1;
21
22impl Foo for IsFoo1 {
23 const BAR: u32 = 1;
24}
25
26struct IsFoo2;
223e47cc 27
d9579d0f
AL
28impl Foo for IsFoo2 {
29 const BAR: u32 = <IsFoo1 as Foo>::BAR;
30}
31
32fn main() {
33 assert_eq!(<IsFoo1>::BAR, <IsFoo2 as Foo>::BAR);
c34b1796 34}