Skip to content

Commit c8271c1

Browse files
committed
Added mGCA tests that were resolved
1 parent f57eac1 commit c8271c1

9 files changed

Lines changed: 171 additions & 0 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/141014>
2+
//@ run-pass
3+
#![expect(incomplete_features)]
4+
#![feature(min_generic_const_args)]
5+
#![allow(dead_code)]
6+
7+
trait Abc {}
8+
9+
trait A {
10+
#[type_const]
11+
const VALUE: usize;
12+
}
13+
14+
impl<T: Abc> A for T {
15+
#[type_const]
16+
const VALUE: usize = 0;
17+
}
18+
19+
trait S<const K: usize> {}
20+
21+
trait Handler<T: Abc>
22+
where
23+
(): S<{ <T as A>::VALUE }>,
24+
{
25+
}
26+
27+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/143506>
2+
#![expect(incomplete_features)]
3+
#![feature(generic_const_exprs)]
4+
#![feature(min_generic_const_args)]
5+
6+
fn foo<const N: u32>(a: [(); N as usize]) {}
7+
//~^ ERROR: complex const arguments must be placed inside of a `const` block
8+
9+
const C: f32 = 1.0;
10+
11+
fn main() {
12+
foo::<C>([]);
13+
//~^ ERROR: the constant `C` is not of type `u32`
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: complex const arguments must be placed inside of a `const` block
2+
--> $DIR/cast-with-type-mismatched.rs:6:30
3+
|
4+
LL | fn foo<const N: u32>(a: [(); N as usize]) {}
5+
| ^^^^^^^^^^
6+
7+
error: the constant `C` is not of type `u32`
8+
--> $DIR/cast-with-type-mismatched.rs:12:11
9+
|
10+
LL | foo::<C>([]);
11+
| ^ expected `u32`, found `f32`
12+
|
13+
note: required by a const generic parameter in `foo`
14+
--> $DIR/cast-with-type-mismatched.rs:6:8
15+
|
16+
LL | fn foo<const N: u32>(a: [(); N as usize]) {}
17+
| ^^^^^^^^^^^^ required by this const generic parameter in `foo`
18+
19+
error: aborting due to 2 previous errors
20+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/139259>
2+
#![expect(incomplete_features)]
3+
#![feature(generic_const_exprs)]
4+
#![feature(min_generic_const_args)]
5+
6+
// The previous ICE was an "invalid field access on immediate".
7+
// If we remove `val: i32` from the field, another ICE occurs.
8+
// "assertion `left == right` failed: invalid field type in
9+
// Immediate::offset: scalar value has wrong size"
10+
struct A {
11+
arr: usize,
12+
val: i32,
13+
}
14+
15+
struct B<const N: A> {
16+
//~^ ERROR: `A` is forbidden as the type of a const generic parameter
17+
arr: [u8; N.arr],
18+
//~^ ERROR: complex const arguments must be placed inside of a `const` block
19+
}
20+
21+
const C: u32 = 1;
22+
fn main() {
23+
let b = B::<C> {arr: [1]};
24+
//~^ ERROR: the constant `C` is not of type `A`
25+
let _ = b.arr.len();
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error: complex const arguments must be placed inside of a `const` block
2+
--> $DIR/const-eval-with-invalid-args.rs:17:15
3+
|
4+
LL | arr: [u8; N.arr],
5+
| ^^^^^
6+
7+
error: `A` is forbidden as the type of a const generic parameter
8+
--> $DIR/const-eval-with-invalid-args.rs:15:19
9+
|
10+
LL | struct B<const N: A> {
11+
| ^
12+
|
13+
= note: the only supported types are integers, `bool`, and `char`
14+
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
15+
|
16+
LL + #![feature(adt_const_params)]
17+
|
18+
19+
error: the constant `C` is not of type `A`
20+
--> $DIR/const-eval-with-invalid-args.rs:23:17
21+
|
22+
LL | let b = B::<C> {arr: [1]};
23+
| ^ expected `A`, found `u32`
24+
|
25+
note: required by a const generic parameter in `B`
26+
--> $DIR/const-eval-with-invalid-args.rs:15:10
27+
|
28+
LL | struct B<const N: A> {
29+
| ^^^^^^^^^^ required by this const generic parameter in `B`
30+
31+
error: aborting due to 3 previous errors
32+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/143358>
2+
#![expect(incomplete_features)]
3+
#![feature(generic_const_exprs)]
4+
#![feature(min_generic_const_args)]
5+
6+
fn identity<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
7+
//~^ ERROR: free function without a body
8+
//~| ERROR: expected type, found function `identity`
9+
//~| ERROR: complex const arguments must be placed inside of a `const` block
10+
11+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: free function without a body
2+
--> $DIR/recursive-self-referencing-const-param.rs:6:1
3+
|
4+
LL | fn identity<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
6+
| |
7+
| help: provide a definition for the function: `{ <body> }`
8+
9+
error[E0573]: expected type, found function `identity`
10+
--> $DIR/recursive-self-referencing-const-param.rs:6:22
11+
|
12+
LL | fn identity<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type
14+
15+
error: complex const arguments must be placed inside of a `const` block
16+
--> $DIR/recursive-self-referencing-const-param.rs:6:57
17+
|
18+
LL | fn identity<const T: identity<{ identity::<{ identity::<{}> }>() }>>();
19+
| ^^
20+
21+
error: aborting due to 3 previous errors
22+
23+
For more information about this error, try `rustc --explain E0573`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/147415>
2+
#![expect(incomplete_features)]
3+
#![feature(min_generic_const_args)]
4+
5+
fn foo<T>() {
6+
[0; size_of::<*mut T>()];
7+
//~^ ERROR: tuple constructor with invalid base path
8+
}
9+
10+
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: tuple constructor with invalid base path
2+
--> $DIR/size-of-generic-ptr-in-array-len.rs:6:9
3+
|
4+
LL | [0; size_of::<*mut T>()];
5+
| ^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)