rust/tests/ui/consts/const-eval/issue-50814.rs
Gurinder Singh 5010ca001c Enable ConstPropLint for promoteds
This fixes the issue wherein the lint didn't fire for promoteds
in the case of SHL/SHR operators in non-optimized builds
and all arithmetic operators in optimized builds
2024-02-17 10:44:46 +05:30

28 lines
485 B
Rust

//@ build-fail
trait Unsigned {
const MAX: u8;
}
struct U8(u8);
impl Unsigned for U8 {
const MAX: u8 = 0xff;
}
struct Sum<A, B>(A, B);
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
const MAX: u8 = A::MAX + B::MAX;
//~^ 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 {
&Sum::<U8, U8>::MAX
//~^ constant
}
fn main() {
foo(0);
}