From c8271c1daffb9f847147f852a6325304269d064e Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 10 Jan 2026 02:07:15 +0900 Subject: [PATCH 1/2] Added mGCA tests that were resolved --- .../mgca/assoc-const-projection-in-bound.rs | 27 ++++++++++++++++ .../mgca/cast-with-type-mismatched.rs | 14 ++++++++ .../mgca/cast-with-type-mismatched.stderr | 20 ++++++++++++ .../mgca/const-eval-with-invalid-args.rs | 26 +++++++++++++++ .../mgca/const-eval-with-invalid-args.stderr | 32 +++++++++++++++++++ .../recursive-self-referencing-const-param.rs | 11 +++++++ ...ursive-self-referencing-const-param.stderr | 23 +++++++++++++ .../mgca/size-of-generic-ptr-in-array-len.rs | 10 ++++++ .../size-of-generic-ptr-in-array-len.stderr | 8 +++++ 9 files changed, 171 insertions(+) create mode 100644 tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs create mode 100644 tests/ui/const-generics/mgca/cast-with-type-mismatched.rs create mode 100644 tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr create mode 100644 tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs create mode 100644 tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr create mode 100644 tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs create mode 100644 tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr create mode 100644 tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs create mode 100644 tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs new file mode 100644 index 000000000000..460e14359483 --- /dev/null +++ b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs @@ -0,0 +1,27 @@ +//! regression test for +//@ run-pass +#![expect(incomplete_features)] +#![feature(min_generic_const_args)] +#![allow(dead_code)] + +trait Abc {} + +trait A { + #[type_const] + const VALUE: usize; +} + +impl A for T { + #[type_const] + const VALUE: usize = 0; +} + +trait S {} + +trait Handler +where + (): S<{ ::VALUE }>, +{ +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs b/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs new file mode 100644 index 000000000000..1f499c222e7f --- /dev/null +++ b/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs @@ -0,0 +1,14 @@ +//! regression test for +#![expect(incomplete_features)] +#![feature(generic_const_exprs)] +#![feature(min_generic_const_args)] + +fn foo(a: [(); N as usize]) {} +//~^ ERROR: complex const arguments must be placed inside of a `const` block + +const C: f32 = 1.0; + +fn main() { + foo::([]); + //~^ ERROR: the constant `C` is not of type `u32` +} diff --git a/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr b/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr new file mode 100644 index 000000000000..7e1b21138ec8 --- /dev/null +++ b/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr @@ -0,0 +1,20 @@ +error: complex const arguments must be placed inside of a `const` block + --> $DIR/cast-with-type-mismatched.rs:6:30 + | +LL | fn foo(a: [(); N as usize]) {} + | ^^^^^^^^^^ + +error: the constant `C` is not of type `u32` + --> $DIR/cast-with-type-mismatched.rs:12:11 + | +LL | foo::([]); + | ^ expected `u32`, found `f32` + | +note: required by a const generic parameter in `foo` + --> $DIR/cast-with-type-mismatched.rs:6:8 + | +LL | fn foo(a: [(); N as usize]) {} + | ^^^^^^^^^^^^ required by this const generic parameter in `foo` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs new file mode 100644 index 000000000000..3bf951e0c212 --- /dev/null +++ b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs @@ -0,0 +1,26 @@ +//! regression test for +#![expect(incomplete_features)] +#![feature(generic_const_exprs)] +#![feature(min_generic_const_args)] + +// The previous ICE was an "invalid field access on immediate". +// If we remove `val: i32` from the field, another ICE occurs. +// "assertion `left == right` failed: invalid field type in +// Immediate::offset: scalar value has wrong size" +struct A { + arr: usize, + val: i32, +} + +struct B { + //~^ ERROR: `A` is forbidden as the type of a const generic parameter + arr: [u8; N.arr], + //~^ ERROR: complex const arguments must be placed inside of a `const` block +} + +const C: u32 = 1; +fn main() { + let b = B:: {arr: [1]}; + //~^ ERROR: the constant `C` is not of type `A` + let _ = b.arr.len(); +} diff --git a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr new file mode 100644 index 000000000000..a226718ccf1b --- /dev/null +++ b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr @@ -0,0 +1,32 @@ +error: complex const arguments must be placed inside of a `const` block + --> $DIR/const-eval-with-invalid-args.rs:17:15 + | +LL | arr: [u8; N.arr], + | ^^^^^ + +error: `A` is forbidden as the type of a const generic parameter + --> $DIR/const-eval-with-invalid-args.rs:15:19 + | +LL | struct B { + | ^ + | + = note: the only supported types are integers, `bool`, and `char` +help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + | +LL + #![feature(adt_const_params)] + | + +error: the constant `C` is not of type `A` + --> $DIR/const-eval-with-invalid-args.rs:23:17 + | +LL | let b = B:: {arr: [1]}; + | ^ expected `A`, found `u32` + | +note: required by a const generic parameter in `B` + --> $DIR/const-eval-with-invalid-args.rs:15:10 + | +LL | struct B { + | ^^^^^^^^^^ required by this const generic parameter in `B` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs new file mode 100644 index 000000000000..37dcc58ff468 --- /dev/null +++ b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs @@ -0,0 +1,11 @@ +//! regression test for +#![expect(incomplete_features)] +#![feature(generic_const_exprs)] +#![feature(min_generic_const_args)] + +fn identity }>() }>>(); +//~^ ERROR: free function without a body +//~| ERROR: expected type, found function `identity` +//~| ERROR: complex const arguments must be placed inside of a `const` block + +fn main() {} diff --git a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr new file mode 100644 index 000000000000..d1899c476ec6 --- /dev/null +++ b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr @@ -0,0 +1,23 @@ +error: free function without a body + --> $DIR/recursive-self-referencing-const-param.rs:6:1 + | +LL | fn identity }>() }>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ }` + +error[E0573]: expected type, found function `identity` + --> $DIR/recursive-self-referencing-const-param.rs:6:22 + | +LL | fn identity }>() }>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type + +error: complex const arguments must be placed inside of a `const` block + --> $DIR/recursive-self-referencing-const-param.rs:6:57 + | +LL | fn identity }>() }>>(); + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0573`. diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs new file mode 100644 index 000000000000..2a7c23929845 --- /dev/null +++ b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs @@ -0,0 +1,10 @@ +//! regression test for +#![expect(incomplete_features)] +#![feature(min_generic_const_args)] + +fn foo() { + [0; size_of::<*mut T>()]; + //~^ ERROR: tuple constructor with invalid base path +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr new file mode 100644 index 000000000000..dcdc56a1cf47 --- /dev/null +++ b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr @@ -0,0 +1,8 @@ +error: tuple constructor with invalid base path + --> $DIR/size-of-generic-ptr-in-array-len.rs:6:9 + | +LL | [0; size_of::<*mut T>()]; + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + From 6166b619794ba095919deaad239628ad2ddce3b3 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 12 Jan 2026 00:45:50 +0900 Subject: [PATCH 2/2] Add crashes mGCA tests --- tests/crashes/138226-2.rs | 13 ++++++++ tests/crashes/138226.rs | 13 ++++++++ tests/crashes/149809.rs | 13 ++++++++ tests/crashes/150960.rs | 11 +++++++ .../mgca/cast-with-type-mismatched.rs | 14 -------- .../mgca/cast-with-type-mismatched.stderr | 20 ------------ .../mgca/const-eval-with-invalid-args.rs | 26 --------------- .../mgca/const-eval-with-invalid-args.stderr | 32 ------------------- .../recursive-self-referencing-const-param.rs | 11 ------- ...ursive-self-referencing-const-param.stderr | 23 ------------- .../mgca/size-of-generic-ptr-in-array-len.rs | 2 ++ .../size-of-generic-ptr-in-array-len.stderr | 8 ++++- 12 files changed, 59 insertions(+), 127 deletions(-) create mode 100644 tests/crashes/138226-2.rs create mode 100644 tests/crashes/138226.rs create mode 100644 tests/crashes/149809.rs create mode 100644 tests/crashes/150960.rs delete mode 100644 tests/ui/const-generics/mgca/cast-with-type-mismatched.rs delete mode 100644 tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr delete mode 100644 tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs delete mode 100644 tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr delete mode 100644 tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs delete mode 100644 tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr diff --git a/tests/crashes/138226-2.rs b/tests/crashes/138226-2.rs new file mode 100644 index 000000000000..a2ebbdefdf3f --- /dev/null +++ b/tests/crashes/138226-2.rs @@ -0,0 +1,13 @@ +//@ known-bug: #138226 +//@ needs-rustc-debug-assertions +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +struct Bar; +impl Bar { + #[type_const] + const LEN: usize = 4; + + fn bar() { + let _ = [0; Self::LEN]; + } +} diff --git a/tests/crashes/138226.rs b/tests/crashes/138226.rs new file mode 100644 index 000000000000..7d13461a56b3 --- /dev/null +++ b/tests/crashes/138226.rs @@ -0,0 +1,13 @@ +//@ known-bug: #138226 +//@ needs-rustc-debug-assertions +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +struct Foo(A, B); +impl Foo { + #[type_const] + const LEN: usize = 4; + + fn foo() { + let _ = [5; Self::LEN]; + } +} diff --git a/tests/crashes/149809.rs b/tests/crashes/149809.rs new file mode 100644 index 000000000000..2b948e9079c3 --- /dev/null +++ b/tests/crashes/149809.rs @@ -0,0 +1,13 @@ +//@ known-bug: #149809 +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +struct Qux<'a> { + x: &'a (), +} +impl<'a> Qux<'a> { + #[type_const] + const LEN: usize = 4; + fn foo(_: [u8; Qux::LEN]) {} +} + +fn main() {} diff --git a/tests/crashes/150960.rs b/tests/crashes/150960.rs new file mode 100644 index 000000000000..2d46eea67989 --- /dev/null +++ b/tests/crashes/150960.rs @@ -0,0 +1,11 @@ +//@ known-bug: #150960 +#![feature(min_generic_const_args)] +struct Baz; +impl Baz { + #[type_const] + const LEN: usize = 4; + + fn baz() { + let _ = [0; const { Self::LEN }]; + } +} diff --git a/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs b/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs deleted file mode 100644 index 1f499c222e7f..000000000000 --- a/tests/ui/const-generics/mgca/cast-with-type-mismatched.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! regression test for -#![expect(incomplete_features)] -#![feature(generic_const_exprs)] -#![feature(min_generic_const_args)] - -fn foo(a: [(); N as usize]) {} -//~^ ERROR: complex const arguments must be placed inside of a `const` block - -const C: f32 = 1.0; - -fn main() { - foo::([]); - //~^ ERROR: the constant `C` is not of type `u32` -} diff --git a/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr b/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr deleted file mode 100644 index 7e1b21138ec8..000000000000 --- a/tests/ui/const-generics/mgca/cast-with-type-mismatched.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/cast-with-type-mismatched.rs:6:30 - | -LL | fn foo(a: [(); N as usize]) {} - | ^^^^^^^^^^ - -error: the constant `C` is not of type `u32` - --> $DIR/cast-with-type-mismatched.rs:12:11 - | -LL | foo::([]); - | ^ expected `u32`, found `f32` - | -note: required by a const generic parameter in `foo` - --> $DIR/cast-with-type-mismatched.rs:6:8 - | -LL | fn foo(a: [(); N as usize]) {} - | ^^^^^^^^^^^^ required by this const generic parameter in `foo` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs deleted file mode 100644 index 3bf951e0c212..000000000000 --- a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! regression test for -#![expect(incomplete_features)] -#![feature(generic_const_exprs)] -#![feature(min_generic_const_args)] - -// The previous ICE was an "invalid field access on immediate". -// If we remove `val: i32` from the field, another ICE occurs. -// "assertion `left == right` failed: invalid field type in -// Immediate::offset: scalar value has wrong size" -struct A { - arr: usize, - val: i32, -} - -struct B { - //~^ ERROR: `A` is forbidden as the type of a const generic parameter - arr: [u8; N.arr], - //~^ ERROR: complex const arguments must be placed inside of a `const` block -} - -const C: u32 = 1; -fn main() { - let b = B:: {arr: [1]}; - //~^ ERROR: the constant `C` is not of type `A` - let _ = b.arr.len(); -} diff --git a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr b/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr deleted file mode 100644 index a226718ccf1b..000000000000 --- a/tests/ui/const-generics/mgca/const-eval-with-invalid-args.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: complex const arguments must be placed inside of a `const` block - --> $DIR/const-eval-with-invalid-args.rs:17:15 - | -LL | arr: [u8; N.arr], - | ^^^^^ - -error: `A` is forbidden as the type of a const generic parameter - --> $DIR/const-eval-with-invalid-args.rs:15:19 - | -LL | struct B { - | ^ - | - = note: the only supported types are integers, `bool`, and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: the constant `C` is not of type `A` - --> $DIR/const-eval-with-invalid-args.rs:23:17 - | -LL | let b = B:: {arr: [1]}; - | ^ expected `A`, found `u32` - | -note: required by a const generic parameter in `B` - --> $DIR/const-eval-with-invalid-args.rs:15:10 - | -LL | struct B { - | ^^^^^^^^^^ required by this const generic parameter in `B` - -error: aborting due to 3 previous errors - diff --git a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs deleted file mode 100644 index 37dcc58ff468..000000000000 --- a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! regression test for -#![expect(incomplete_features)] -#![feature(generic_const_exprs)] -#![feature(min_generic_const_args)] - -fn identity }>() }>>(); -//~^ ERROR: free function without a body -//~| ERROR: expected type, found function `identity` -//~| ERROR: complex const arguments must be placed inside of a `const` block - -fn main() {} diff --git a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr b/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr deleted file mode 100644 index d1899c476ec6..000000000000 --- a/tests/ui/const-generics/mgca/recursive-self-referencing-const-param.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: free function without a body - --> $DIR/recursive-self-referencing-const-param.rs:6:1 - | -LL | fn identity }>() }>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: provide a definition for the function: `{ }` - -error[E0573]: expected type, found function `identity` - --> $DIR/recursive-self-referencing-const-param.rs:6:22 - | -LL | fn identity }>() }>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type - -error: complex const arguments must be placed inside of a `const` block - --> $DIR/recursive-self-referencing-const-param.rs:6:57 - | -LL | fn identity }>() }>>(); - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0573`. diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs index 2a7c23929845..22963b6438c0 100644 --- a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs +++ b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs @@ -5,6 +5,8 @@ fn foo() { [0; size_of::<*mut T>()]; //~^ ERROR: tuple constructor with invalid base path + [0; const { size_of::<*mut T>() }]; + //~^ ERROR: generic parameters may not be used in const operations } fn main() {} diff --git a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr index dcdc56a1cf47..913d8195fe21 100644 --- a/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr +++ b/tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr @@ -4,5 +4,11 @@ error: tuple constructor with invalid base path LL | [0; size_of::<*mut T>()]; | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: generic parameters may not be used in const operations + --> $DIR/size-of-generic-ptr-in-array-len.rs:8:32 + | +LL | [0; const { size_of::<*mut T>() }]; + | ^ + +error: aborting due to 2 previous errors