]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/const_evaluatable_checked/infer-too-generic.rs
Merge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelift-rebase
[rust.git] / src / test / ui / const-generics / const_evaluatable_checked / infer-too-generic.rs
1 // run-pass
2 #![feature(const_generics, const_evaluatable_checked)]
3 #![allow(incomplete_features)]
4
5 use std::{mem, ptr};
6
7 fn split_first<T, const N: usize>(arr: [T; N]) -> (T, [T; N - 1])
8 where
9     [T; N - 1]: Sized,
10 {
11     let arr = mem::ManuallyDrop::new(arr);
12     unsafe {
13         let head = ptr::read(&arr[0]);
14         let tail = ptr::read(&arr[1..] as *const [T] as *const [T; N - 1]);
15         (head, tail)
16     }
17 }
18
19 fn main() {
20     let arr = [0, 1, 2, 3, 4];
21     let (head, tail) = split_first(arr);
22     assert_eq!(head, 0);
23     assert_eq!(tail, [1, 2, 3, 4]);
24 }