From 1df876f4c0ab583ef8821739c38340c8062f2ed5 Mon Sep 17 00:00:00 2001 From: Boxy Date: Tue, 2 Jul 2024 16:28:01 +0100 Subject: [PATCH] Add test --- .../nested_bad_const_param_ty.rs | 18 +++++++ .../nested_bad_const_param_ty.stderr | 51 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs create mode 100644 tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr diff --git a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs new file mode 100644 index 00000000000..9f05c53eef0 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.rs @@ -0,0 +1,18 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +#[derive(ConstParamTy)] +//~^ the trait `ConstParamTy` cannot be implemented for this ty +struct Foo([*const u8; 1]); + +#[derive(ConstParamTy)] +//~^ the trait `ConstParamTy` cannot be implemented for this ty +struct Foo2([*mut u8; 1]); + +#[derive(ConstParamTy)] +//~^ the trait `ConstParamTy` cannot be implemented for this ty +struct Foo3([fn(); 1]); + +fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr new file mode 100644 index 00000000000..9e772e8d55d --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/nested_bad_const_param_ty.stderr @@ -0,0 +1,51 @@ +error[E0204]: the trait `ConstParamTy` cannot be implemented for this type + --> $DIR/nested_bad_const_param_ty.rs:6:10 + | +LL | #[derive(ConstParamTy)] + | ^^^^^^^^^^^^ +LL | +LL | struct Foo([*const u8; 1]); + | -------------- this field does not implement `ConstParamTy` + | +note: the `ConstParamTy` impl for `[*const u8; 1]` requires that `*const u8: ConstParamTy` + --> $DIR/nested_bad_const_param_ty.rs:8:12 + | +LL | struct Foo([*const u8; 1]); + | ^^^^^^^^^^^^^^ + = note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0204]: the trait `ConstParamTy` cannot be implemented for this type + --> $DIR/nested_bad_const_param_ty.rs:10:10 + | +LL | #[derive(ConstParamTy)] + | ^^^^^^^^^^^^ +LL | +LL | struct Foo2([*mut u8; 1]); + | ------------ this field does not implement `ConstParamTy` + | +note: the `ConstParamTy` impl for `[*mut u8; 1]` requires that `*mut u8: ConstParamTy` + --> $DIR/nested_bad_const_param_ty.rs:12:13 + | +LL | struct Foo2([*mut u8; 1]); + | ^^^^^^^^^^^^ + = note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0204]: the trait `ConstParamTy` cannot be implemented for this type + --> $DIR/nested_bad_const_param_ty.rs:14:10 + | +LL | #[derive(ConstParamTy)] + | ^^^^^^^^^^^^ +LL | +LL | struct Foo3([fn(); 1]); + | --------- this field does not implement `ConstParamTy` + | +note: the `ConstParamTy` impl for `[fn(); 1]` requires that `fn(): ConstParamTy` + --> $DIR/nested_bad_const_param_ty.rs:16:13 + | +LL | struct Foo3([fn(); 1]); + | ^^^^^^^^^ + = note: this error originates in the derive macro `ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0204`.