Rollup merge of #150886 - mgca-test, r=BoxyUwU

Added mGCA related tests

Add regression tests for subsequent mGCA tasks

edit:

resolve: https://github.com/rust-lang/rust/issues/147415 `tests\ui\const-generics\mgca\size-of-generic-ptr-in-array-len.rs`
resolve: https://github.com/rust-lang/rust/issues/141014 `tests\ui\const-generics\mgca\assoc-const-projection-in-bound.rs`

and crashes: 138226, 138226-2, 149809, 150960
This commit is contained in:
Jonathan Brouwer 2026-01-18 18:26:03 +01:00 committed by GitHub
commit 57edde388b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 103 additions and 0 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

@ -0,0 +1,27 @@
//! regression test for <https://github.com/rust-lang/rust/issues/141014>
//@ run-pass
#![expect(incomplete_features)]
#![feature(min_generic_const_args)]
#![allow(dead_code)]
trait Abc {}
trait A {
#[type_const]
const VALUE: usize;
}
impl<T: Abc> A for T {
#[type_const]
const VALUE: usize = 0;
}
trait S<const K: usize> {}
trait Handler<T: Abc>
where
(): S<{ <T as A>::VALUE }>,
{
}
fn main() {}

View file

@ -0,0 +1,12 @@
//! regression test for <https://github.com/rust-lang/rust/issues/147415>
#![expect(incomplete_features)]
#![feature(min_generic_const_args)]
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

@ -0,0 +1,14 @@
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: 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