diff options
Diffstat (limited to 'src/test')
8 files changed, 89 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issue-61422.rs b/src/test/ui/const-generics/issue-61422.rs new file mode 100644 index 00000000000..3ccf38e5619 --- /dev/null +++ b/src/test/ui/const-generics/issue-61422.rs @@ -0,0 +1,15 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +use std::mem; + +fn foo<const SIZE: usize>() { + let arr: [u8; SIZE] = unsafe { + let mut array: [u8; SIZE] = mem::uninitialized(); + array + }; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issue-61422.stderr b/src/test/ui/const-generics/issue-61422.stderr new file mode 100644 index 00000000000..4cb76ec4fe1 --- /dev/null +++ b/src/test/ui/const-generics/issue-61422.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-61422.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.rs b/src/test/ui/const-generics/mut-ref-const-param-array.rs new file mode 100644 index 00000000000..f930fb87963 --- /dev/null +++ b/src/test/ui/const-generics/mut-ref-const-param-array.rs @@ -0,0 +1,19 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +use std::ops::AddAssign; + +fn inc<T: AddAssign + Clone, const N: usize>(v: &mut [T; N]) -> &mut [T; N] { + for x in v.iter_mut() { + *x += x.clone(); + } + v +} + +fn main() { + let mut v = [1, 2, 3]; + inc(&mut v); + assert_eq!(v, [2, 4, 6]); +} diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.stderr b/src/test/ui/const-generics/mut-ref-const-param-array.stderr new file mode 100644 index 00000000000..261d3578a11 --- /dev/null +++ b/src/test/ui/const-generics/mut-ref-const-param-array.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/mut-ref-const-param-array.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs new file mode 100644 index 00000000000..794048174f9 --- /dev/null +++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs @@ -0,0 +1,11 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +use std::mem::MaybeUninit; + +#[repr(transparent)] +pub struct MaybeUninitWrapper<const N: usize>(MaybeUninit<[u64; N]>); + +fn main() {} diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.stderr b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.stderr new file mode 100644 index 00000000000..661bbd113bc --- /dev/null +++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/transparent-maybeunit-array-wrapper.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + diff --git a/src/test/ui/error-codes/E0730.rs b/src/test/ui/error-codes/E0730.rs new file mode 100644 index 00000000000..e5048d6e6e3 --- /dev/null +++ b/src/test/ui/error-codes/E0730.rs @@ -0,0 +1,11 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +fn is_123<const N: usize>(x: [u32; N]) -> bool { + match x { + [1, 2, 3] => true, //~ ERROR cannot pattern-match on an array without a fixed length + _ => false + } +} + +fn main() {} diff --git a/src/test/ui/error-codes/E0730.stderr b/src/test/ui/error-codes/E0730.stderr new file mode 100644 index 00000000000..f9281262bb7 --- /dev/null +++ b/src/test/ui/error-codes/E0730.stderr @@ -0,0 +1,15 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/E0730.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error[E0730]: cannot pattern-match on an array without a fixed length + --> $DIR/E0730.rs:6:9 + | +LL | [1, 2, 3] => true, + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0730`. |
