Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/crashes/138226-2.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions tests/crashes/138226.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions tests/crashes/149809.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions tests/crashes/150960.rs
Original file line number Diff line number Diff line change
@@ -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 }];
}
}
27 changes: 27 additions & 0 deletions tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs
Original file line number Diff line number Diff line change
@@ -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 }>,
{
}
Comment on lines +14 to +25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICE was also reproduced in code like this.

https://godbolt.org/z/fbvWGv49a


fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs
Original file line number Diff line number Diff line change
@@ -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>()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a second line for [0; const { 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() {}
Original file line number Diff line number Diff line change
@@ -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

Loading