// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait C { const BOO: usize; } trait Foo { const BAR: usize; } struct A(T); impl Foo for A { const BAR: usize = [5, 6, 7][T::BOO]; } fn foo() -> &'static usize { & as Foo>::BAR //~ ERROR erroneous constant used //~| ERROR E0080 } impl C for () { const BOO: usize = 42; } impl C for u32 { const BOO: usize = 1; } fn main() { println!("{:x}", foo::<()>() as *const usize as usize); println!("{:x}", foo::() as *const usize as usize); println!("{:x}", foo::<()>()); println!("{:x}", foo::()); }