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