Skip to content

Commit

Permalink
add regression tests for rust-lang#67144
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jul 16, 2020
1 parent e2e29de commit e009b53
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/ui/const-generics/type-dependent/issue-67144-1.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions src/test/ui/const-generics/type-dependent/issue-67144-2.rs
Original file line number Diff line number Diff line change
@@ -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>();
}

0 comments on commit e009b53

Please sign in to comment.