add regression tests for #67144
This commit is contained in:
parent
e2e29de5e8
commit
e009b53df4
2 changed files with 50 additions and 0 deletions
28
src/test/ui/const-generics/type-dependent/issue-67144-1.rs
Normal file
28
src/test/ui/const-generics/type-dependent/issue-67144-1.rs
Normal 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>();
|
||||
}
|
||||
22
src/test/ui/const-generics/type-dependent/issue-67144-2.rs
Normal file
22
src/test/ui/const-generics/type-dependent/issue-67144-2.rs
Normal 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>();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue