Add crashes mGCA tests

This commit is contained in:
reddevilmidzy 2026-01-12 00:45:50 +09:00
parent c8271c1daf
commit 6166b61979
12 changed files with 59 additions and 127 deletions

13
tests/crashes/138226-2.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #138226
//@ needs-rustc-debug-assertions
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct Bar<const N: usize>;
impl<const N: usize> Bar<N> {
#[type_const]
const LEN: usize = 4;
fn bar() {
let _ = [0; Self::LEN];
}
}

13
tests/crashes/138226.rs Normal file
View file

@ -0,0 +1,13 @@
//@ known-bug: #138226
//@ needs-rustc-debug-assertions
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct Foo<A, B>(A, B);
impl<A, B> Foo<A, B> {
#[type_const]
const LEN: usize = 4;
fn foo() {
let _ = [5; Self::LEN];
}
}

13
tests/crashes/149809.rs Normal file
View file

@ -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() {}

11
tests/crashes/150960.rs Normal file
View file

@ -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 }];
}
}

View file

@ -1,14 +0,0 @@
//! regression test for <https://github.com/rust-lang/rust/issues/143506>
#![expect(incomplete_features)]
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
fn foo<const N: u32>(a: [(); N as usize]) {}
//~^ ERROR: complex const arguments must be placed inside of a `const` block
const C: f32 = 1.0;
fn main() {
foo::<C>([]);
//~^ ERROR: the constant `C` is not of type `u32`
}

View file

@ -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<const N: u32>(a: [(); N as usize]) {}
| ^^^^^^^^^^
error: the constant `C` is not of type `u32`
--> $DIR/cast-with-type-mismatched.rs:12:11
|
LL | foo::<C>([]);
| ^ expected `u32`, found `f32`
|
note: required by a const generic parameter in `foo`
--> $DIR/cast-with-type-mismatched.rs:6:8
|
LL | fn foo<const N: u32>(a: [(); N as usize]) {}
| ^^^^^^^^^^^^ required by this const generic parameter in `foo`
error: aborting due to 2 previous errors

View file

@ -1,26 +0,0 @@
//! regression test for <https://github.com/rust-lang/rust/issues/139259>
#![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<const N: A> {
//~^ 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::<C> {arr: [1]};
//~^ ERROR: the constant `C` is not of type `A`
let _ = b.arr.len();
}

View file

@ -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<const N: A> {
| ^
|
= 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::<C> {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<const N: A> {
| ^^^^^^^^^^ required by this const generic parameter in `B`
error: aborting due to 3 previous errors

View file

@ -1,11 +0,0 @@
//! regression test for <https://github.com/rust-lang/rust/issues/143358>
#![expect(incomplete_features)]
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
fn identity<const T: identity<{ identity::<{ 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() {}

View file

@ -1,23 +0,0 @@
error: free function without a body
--> $DIR/recursive-self-referencing-const-param.rs:6:1
|
LL | fn identity<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
error[E0573]: expected type, found function `identity`
--> $DIR/recursive-self-referencing-const-param.rs:6:22
|
LL | fn identity<const T: identity<{ identity::<{ 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<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
| ^^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0573`.

View file

@ -5,6 +5,8 @@
fn foo<T>() {
[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() {}

View file

@ -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