diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/const-generics/type-dependent/issue-67144-1.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs new file mode 100644 index 000000000..27dd51de2 --- /dev/null +++ b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs @@ -0,0 +1,25 @@ +// check-pass +struct X; + +impl X { + pub fn getn<const N: usize>(&self) -> [u8; N] { + getn::<N>() + } +} + +fn getn<const N: usize>() -> [u8; N] { + unsafe { + std::mem::zeroed() + } +} + +fn main() { + // works + let [a,b,c] = getn::<3>(); + + // cannot pattern-match on an array without a fixed length + let [a,b,c] = X.getn::<3>(); + + // mismatched types, expected array `[u8; 3]` found array `[u8; _]` + let arr: [u8; 3] = X.getn::<3>(); +} |