]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs
Update tests to remove old numeric constants
[rust.git] / src / test / ui / const-generics / const_evaluatable_checked / fn_call.rs
1 // run-pass
2 #![feature(const_generics, const_evaluatable_checked)]
3 #![allow(incomplete_features)]
4
5 const fn test_me<T>(a: usize, b: usize) -> usize {
6     if a < b {
7         std::mem::size_of::<T>()
8     } else {
9         usize::MAX
10     }
11 }
12
13 fn test_simple<T>() -> [u8; std::mem::size_of::<T>()]
14 where
15     [u8; std::mem::size_of::<T>()]: Sized,
16 {
17     [0; std::mem::size_of::<T>()]
18 }
19
20 fn test_with_args<T, const N: usize>() -> [u8; test_me::<T>(N, N + 1) + N]
21 where
22     [u8; test_me::<T>(N, N + 1) + N]: Sized,
23 {
24     [0; test_me::<T>(N, N + 1) + N]
25 }
26
27 fn main() {
28     assert_eq!([0; 8], test_simple::<u64>());
29     assert_eq!([0; 12], test_with_args::<u64, 4>());
30 }