]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/type-dependent/issue-67144-1.rs
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / ui / const-generics / type-dependent / issue-67144-1.rs
1 // check-pass
2 struct X;
3
4 impl X {
5     pub fn getn<const N: usize>(&self) -> [u8; N] {
6         getn::<N>()
7     }
8 }
9
10 fn getn<const N: usize>() -> [u8; N] {
11     unsafe {
12         std::mem::zeroed()
13     }
14 }
15
16 fn main() {
17     // works
18     let [a,b,c] = getn::<3>();
19
20     // cannot pattern-match on an array without a fixed length
21     let [a,b,c] = X.getn::<3>();
22
23     // mismatched types, expected array `[u8; 3]` found array `[u8; _]`
24     let arr: [u8; 3] = X.getn::<3>();
25 }