]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/issue-50814.rs
Rollup merge of #104076 - ozkanonur:fix-ci-rustc-sysroot, r=jyn514
[rust.git] / src / test / ui / consts / const-eval / issue-50814.rs
1 // build-fail
2
3 trait Unsigned {
4     const MAX: u8;
5 }
6
7 struct U8(u8);
8 impl Unsigned for U8 {
9     const MAX: u8 = 0xff;
10 }
11
12 struct Sum<A, B>(A, B);
13
14 impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
15     const MAX: u8 = A::MAX + B::MAX;
16     //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
17 }
18
19 fn foo<T>(_: T) -> &'static u8 {
20     &Sum::<U8, U8>::MAX
21     //~^ constant
22 }
23
24 fn main() {
25     foo(0);
26 }