From 0fdd4191adb998991742c7f63f49b1a6c4e4ec3d Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 30 May 2019 19:55:43 +0100 Subject: [PATCH] Add regression test for const generics ICE Co-Authored-By: Mazdak Farrokhzad --- .../const-generic-array-wrapper.rs | 18 ++++++++++++++++++ .../const-generic-array-wrapper.stderr | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/const-generics/const-generic-array-wrapper.rs create mode 100644 src/test/ui/const-generics/const-generic-array-wrapper.stderr diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.rs b/src/test/ui/const-generics/const-generic-array-wrapper.rs new file mode 100644 index 0000000000000..adffe32d67a30 --- /dev/null +++ b/src/test/ui/const-generics/const-generic-array-wrapper.rs @@ -0,0 +1,18 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Foo([T; {N}]); + +impl Foo { + fn foo(&self) -> usize { + {N} + } +} + +fn main() { + let foo = Foo([0u32; 21]); + assert_eq!(foo.0, [0u32; 21]); + assert_eq!(foo.foo(), 21); +} diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.stderr b/src/test/ui/const-generics/const-generic-array-wrapper.stderr new file mode 100644 index 0000000000000..f92e11d47ed37 --- /dev/null +++ b/src/test/ui/const-generics/const-generic-array-wrapper.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/const-generic-array-wrapper.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ +