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