]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/issue-50814.rs
8f2752453b52eb176980bc846f46240f17d4a558
[rust.git] / src / test / ui / consts / const-eval / issue-50814.rs
1 // Copyright 2018 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 trait Unsigned {
12     const MAX: u8;
13 }
14
15 struct U8(u8);
16 impl Unsigned for U8 {
17     const MAX: u8 = 0xff;
18 }
19
20 struct Sum<A,B>(A,B);
21
22 impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A,B> {
23     const MAX: u8 = A::MAX + B::MAX;
24 }
25
26 fn foo<T>(_: T) -> &'static u8 {
27     &Sum::<U8,U8>::MAX //~ ERROR erroneous constant used
28 //~| ERROR E0080
29 }
30
31 fn main() {
32     foo(0);
33 }