2019-12-13 21:28:32 -06:00
|
|
|
//@ build-fail
|
|
|
|
|
2018-06-02 19:04:20 -05:00
|
|
|
trait Unsigned {
|
|
|
|
const MAX: u8;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct U8(u8);
|
|
|
|
impl Unsigned for U8 {
|
|
|
|
const MAX: u8 = 0xff;
|
|
|
|
}
|
|
|
|
|
2022-10-15 10:26:11 -05:00
|
|
|
struct Sum<A, B>(A, B);
|
2018-06-02 19:04:20 -05:00
|
|
|
|
2022-10-15 10:26:11 -05:00
|
|
|
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
|
2019-11-22 14:26:09 -06:00
|
|
|
const MAX: u8 = A::MAX + B::MAX;
|
2022-09-21 06:05:20 -05:00
|
|
|
//~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
|
2024-02-16 23:14:46 -06:00
|
|
|
//~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
|
2018-06-02 19:04:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn foo<T>(_: T) -> &'static u8 {
|
2022-10-15 10:26:11 -05:00
|
|
|
&Sum::<U8, U8>::MAX
|
2022-11-15 05:06:20 -06:00
|
|
|
//~^ constant
|
2018-06-02 19:04:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo(0);
|
2018-06-02 20:39:26 -05:00
|
|
|
}
|