From 51355ad92b6a98a38e72f4e1c168abd494b59160 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 3 Mar 2023 18:20:17 +0000 Subject: [PATCH] Add a test for `[NotParam; 0]: ConstParamTy` (not holding) --- .../const_param_ty_bad_empty_array.rs | 12 ++++++++++++ .../const_param_ty_bad_empty_array.stderr | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs create mode 100644 tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs new file mode 100644 index 00000000000..b0e3b13cc1e --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs @@ -0,0 +1,12 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +#[derive(PartialEq, Eq)] +struct NotParam; + +fn check() {} + +fn main() { + check::<[NotParam; 0]>(); + //~^ error: `NotParam` can't be used as a const parameter type +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr new file mode 100644 index 00000000000..ef55242df87 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr @@ -0,0 +1,16 @@ +error[E0277]: `NotParam` can't be used as a const parameter type + --> $DIR/const_param_ty_bad_empty_array.rs:10:13 + | +LL | check::<[NotParam; 0]>(); + | ^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam` + | + = note: required for `[NotParam; 0]` to implement `ConstParamTy` +note: required by a bound in `check` + --> $DIR/const_param_ty_bad_empty_array.rs:7:13 + | +LL | fn check() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`.