]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/auxiliary/post_monomorphization_error.rs
Rollup merge of #80543 - LeSeulArtichaut:notify-close, r=spastorino
[rust.git] / src / test / ui / consts / const-eval / auxiliary / post_monomorphization_error.rs
1 // Auxiliary crate used for testing post-monomorphization errors cross-crate.
2 // It duplicates the setup used in `stdarch` to validate its intrinsics' const arguments.
3
4 struct ValidateConstImm<const IMM: i32, const MIN: i32, const MAX: i32>;
5 impl<const IMM: i32, const MIN: i32, const MAX: i32> ValidateConstImm<IMM, MIN, MAX> {
6     pub(crate) const VALID: () = {
7         let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize);
8     };
9 }
10
11 macro_rules! static_assert_imm1 {
12     ($imm:ident) => {
13         let _ = $crate::ValidateConstImm::<$imm, 0, { (1 << 1) - 1 }>::VALID;
14     };
15 }
16
17 // This function triggers an error whenever the const argument does not fit in 1-bit.
18 pub fn stdarch_intrinsic<const IMM1: i32>() {
19     static_assert_imm1!(IMM1);
20 }