Skip to content

Commit 9369cff

Browse files
authored
Rollup merge of rust-lang#152402 - AprilNEA:test/issue-141738-struct-ctor-array-len, r=BoxyUwU
Add regression test for rust-lang#141738 Closes rust-lang#141738 - Add a regression test for rust-lang#141738 - Using a struct constructor (`DefKind::Ctor(Struct, Const)`) as an array repeat count with `#![feature(min_generic_const_args)]` used to ICE in const alias normalization - Fixed by rust-lang#150704, which added const constructor support for mGCA. This test covers the **error path** (struct ctor where `usize` is expected), which was not covered by the tests in rust-lang#150704
2 parents ef776c6 + 8d96e26 commit 9369cff

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/141738
2+
//
3+
// Using a struct constructor as an array repeat count with
4+
// `min_generic_const_args` used to ICE with "unexpected `DefKind`
5+
// for const alias to resolve to: Ctor(Struct, Const)".
6+
// It should now produce a proper type error.
7+
8+
#![feature(min_generic_const_args)]
9+
//~^ WARN the feature `min_generic_const_args` is incomplete
10+
11+
struct S;
12+
13+
fn main() {
14+
let _b = [0; S];
15+
//~^ ERROR the constant `S` is not of type `usize`
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/struct-ctor-in-array-len.rs:8:12
3+
|
4+
LL | #![feature(min_generic_const_args)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: the constant `S` is not of type `usize`
11+
--> $DIR/struct-ctor-in-array-len.rs:14:14
12+
|
13+
LL | let _b = [0; S];
14+
| ^^^^^^ expected `usize`, found `S`
15+
|
16+
= note: the length of array `[{integer}; S]` must be type `usize`
17+
18+
error: aborting due to 1 previous error; 1 warning emitted
19+

0 commit comments

Comments
 (0)