// Copyright 2017 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. // compile-pass #![warn(const_err)] trait Foo { const AMT: usize; } enum Bar { First(A), Second(B), } impl Foo for Bar { const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; } impl Foo for u8 { const AMT: usize = 1; } impl Foo for u16 { const AMT: usize = 2; } fn main() { println!("{}", as Foo>::AMT); //~ WARN const_err //~^ WARN const_err }