Skip to content

Commit e009b53

Browse files
committed
add regression tests for rust-lang#67144
1 parent e2e29de commit e009b53

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
#![feature(const_generics)]
3+
#![allow(incomplete_features)]
4+
5+
struct A<const N: usize>;
6+
7+
struct X;
8+
9+
impl X {
10+
fn inner<const N: usize>() -> A<N> {
11+
outer::<N>()
12+
}
13+
}
14+
15+
fn outer<const N: usize>() -> A<N> {
16+
A
17+
}
18+
19+
fn main() {
20+
let i: A<3usize> = outer::<3usize>();
21+
let o: A<3usize> = X::inner::<3usize>();
22+
}

0 commit comments

Comments
 (0)