rust/tests/ui/consts/const-eval/issue-50814.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
485 B
Rust
Raw Normal View History

//@ build-fail
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);
2022-10-15 10:26:11 -05:00
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
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
//~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
}
fn foo<T>(_: T) -> &'static u8 {
2022-10-15 10:26:11 -05:00
&Sum::<U8, U8>::MAX
//~^ constant
}
fn main() {
foo(0);
2018-06-02 20:39:26 -05:00
}