From 375e17fcb2c1d14dda5b5e4cca29a6d300c4119a Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Sun, 30 Aug 2026 15:43:07 +0330 Subject: [PATCH] Add regression test for unsized const parameter default ICE --- .../unsized-const-param-default.rs | 7 +++++ .../unsized-const-param-default.stderr | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/ui/const-generics/unsized-const-param-default.rs create mode 100644 tests/ui/const-generics/unsized-const-param-default.stderr diff --git a/tests/ui/const-generics/unsized-const-param-default.rs b/tests/ui/const-generics/unsized-const-param-default.rs new file mode 100644 index 0000000000000..0f42f4eacb50a --- /dev/null +++ b/tests/ui/const-generics/unsized-const-param-default.rs @@ -0,0 +1,7 @@ +// Regression test for . + +//@ compile-flags: --crate-type=lib + +struct S; +//~^ ERROR the size for values of type `[()]` cannot be known at compilation time +//~| ERROR `[()]` is forbidden as the type of a const generic parameter diff --git a/tests/ui/const-generics/unsized-const-param-default.stderr b/tests/ui/const-generics/unsized-const-param-default.stderr new file mode 100644 index 0000000000000..f0f2b3b58c77b --- /dev/null +++ b/tests/ui/const-generics/unsized-const-param-default.stderr @@ -0,0 +1,28 @@ +error[E0277]: the size for values of type `[()]` cannot be known at compilation time + --> $DIR/unsized-const-param-default.rs:5:26 + | +LL | struct S; + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[()]` + = note: statics and constants must have a statically known size + +error: `[()]` is forbidden as the type of a const generic parameter + --> $DIR/unsized-const-param-default.rs:5:19 + | +LL | struct S; + | ^^^^ + | + = note: the only supported types are integers, `bool`, and `char` +help: add `#![feature(min_adt_const_params)]` to the crate attributes to enable more complex and user defined types + | +LL + #![feature(min_adt_const_params)] + | +help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait + | +LL + #![feature(unsized_const_params)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`.