From 7030be68aebccb21ce5eb448e982a8c26dcaf62d Mon Sep 17 00:00:00 2001 From: biscuitrescue Date: Mon, 16 Feb 2026 01:35:50 +0530 Subject: [PATCH] move array test to diff file --- .../mgca/array_expr_arg_complex.rs | 16 ++++++++++++++ .../mgca/array_expr_arg_complex.stderr | 14 ++++++++++++ .../mgca/tuple_expr_arg_complex.rs | 6 ----- .../mgca/tuple_expr_arg_complex.stderr | 22 +++++-------------- 4 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 tests/ui/const-generics/mgca/array_expr_arg_complex.rs create mode 100644 tests/ui/const-generics/mgca/array_expr_arg_complex.stderr diff --git a/tests/ui/const-generics/mgca/array_expr_arg_complex.rs b/tests/ui/const-generics/mgca/array_expr_arg_complex.rs new file mode 100644 index 000000000000..6d57e4f4b968 --- /dev/null +++ b/tests/ui/const-generics/mgca/array_expr_arg_complex.rs @@ -0,0 +1,16 @@ +#![feature(min_generic_const_args, adt_const_params, unsized_const_params)] +#![expect(incomplete_features)] + +trait Trait { + type const ASSOC: usize; +} + +fn takes_array() {} +fn takes_tuple_with_array() {} + +fn generic_caller() { + takes_array::<{ [N, N + 1] }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_tuple_with_array::<{ ([N, N + 1], N) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr b/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr new file mode 100644 index 000000000000..f40d4b5035d8 --- /dev/null +++ b/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr @@ -0,0 +1,14 @@ +error: complex const arguments must be placed inside of a `const` block + --> $DIR/array_expr_arg_complex.rs:12:25 + | +LL | takes_array::<{ [N, N + 1] }>(); + | ^^^^^ + +error: complex const arguments must be placed inside of a `const` block + --> $DIR/array_expr_arg_complex.rs:13:37 + | +LL | takes_tuple_with_array::<{ ([N, N + 1], N) }>(); + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs index b3aa8c8b1833..d7cab17bad12 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs @@ -2,14 +2,11 @@ #![expect(incomplete_features)] trait Trait { - type const ASSOC: usize; } fn takes_tuple() {} fn takes_nested_tuple() {} -fn takes_array() {} -fn takes_tuple_with_array() {} fn generic_caller() { takes_tuple::<{ (N, N + 1) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block @@ -17,9 +14,6 @@ fn generic_caller() { takes_nested_tuple::<{ (N, (N, N + 1)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>(); //~ ERROR generic parameters may not be used in const operations - - takes_array::<{ [N, N + 1] }>(); //~ ERROR complex const arguments must be placed inside of a `const` block - takes_tuple_with_array::<{ ([N, N + 1], N) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block } fn main() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr index 24e29bbbe519..95a98d857b1d 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr @@ -1,40 +1,28 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:15:25 + --> $DIR/tuple_expr_arg_complex.rs:12:25 | LL | takes_tuple::<{ (N, N + 1) }>(); | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:16:25 + --> $DIR/tuple_expr_arg_complex.rs:13:25 | LL | takes_tuple::<{ (N, T::ASSOC + 1) }>(); | ^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:18:36 + --> $DIR/tuple_expr_arg_complex.rs:15:36 | LL | takes_nested_tuple::<{ (N, (N, N + 1)) }>(); | ^^^^^ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:21:25 - | -LL | takes_array::<{ [N, N + 1] }>(); - | ^^^^^ - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:22:37 - | -LL | takes_tuple_with_array::<{ ([N, N + 1], N) }>(); - | ^^^^^ - error: generic parameters may not be used in const operations - --> $DIR/tuple_expr_arg_complex.rs:19:44 + --> $DIR/tuple_expr_arg_complex.rs:16:44 | LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>(); | ^ | = help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors