]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/type-dependent/issue-67144-1.rs
Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup
[rust.git] / src / test / ui / const-generics / type-dependent / issue-67144-1.rs
1 // check-pass
2 #![feature(const_generics)]
3 #![allow(incomplete_features)]
4
5 struct X;
6
7 impl X {
8     pub fn getn<const N: usize>(&self) -> [u8; N] {
9         getn::<N>()
10     }
11 }
12
13 fn getn<const N: usize>() -> [u8; N] {
14     unsafe {
15         std::mem::zeroed()
16     }
17 }
18
19 fn main() {
20     // works
21     let [a,b,c] = getn::<3>();
22
23     // cannot pattern-match on an array without a fixed length
24     let [a,b,c] = X.getn::<3>();
25
26     // mismatched types, expected array `[u8; 3]` found array `[u8; _]`
27     let arr: [u8; 3] = X.getn::<3>();
28 }