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
16 changes: 16 additions & 0 deletions tests/ui/const-generics/mgca/struct-ctor-in-array-len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Regression test for https://github.com/rust-lang/rust/issues/141738
//
// Using a struct constructor as an array repeat count with
// `min_generic_const_args` used to ICE with "unexpected `DefKind`
// for const alias to resolve to: Ctor(Struct, Const)".
// It should now produce a proper type error.

#![feature(min_generic_const_args)]
//~^ WARN the feature `min_generic_const_args` is incomplete

struct S;

fn main() {
let _b = [0; S];
//~^ ERROR the constant `S` is not of type `usize`
}
19 changes: 19 additions & 0 deletions tests/ui/const-generics/mgca/struct-ctor-in-array-len.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/struct-ctor-in-array-len.rs:8:12
|
LL | #![feature(min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default

error: the constant `S` is not of type `usize`
--> $DIR/struct-ctor-in-array-len.rs:14:14
|
LL | let _b = [0; S];
| ^^^^^^ expected `usize`, found `S`
|
= note: the length of array `[{integer}; S]` must be type `usize`

error: aborting due to 1 previous error; 1 warning emitted

Loading