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