add regression tests for #67144

This commit is contained in:
Bastian Kauschke 2020-07-16 11:46:39 +02:00
parent e2e29de5e8
commit e009b53df4
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// check-pass
#![feature(const_generics)]
#![allow(incomplete_features)]
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>();
}

View file

@ -0,0 +1,22 @@
// check-pass
#![feature(const_generics)]
#![allow(incomplete_features)]
struct A<const N: usize>;
struct X;
impl X {
fn inner<const N: usize>() -> A<N> {
outer::<N>()
}
}
fn outer<const N: usize>() -> A<N> {
A
}
fn main() {
let i: A<3usize> = outer::<3usize>();
let o: A<3usize> = X::inner::<3usize>();
}