Skip to content

Commit 95ecb63

Browse files
committed
Add regression test for type_const with unit struct ctor under mGCA
Unit struct constructors used as the RHS of a `#[type_const]` associated const used to ICE during normalization because they were lowered as `Const::new_unevaluated` with a Ctor def_id. The compiler now properly constructs a concrete ValTree value for const constructors.
1 parent 035b01b commit 95ecb63

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/148953>
2+
//!
3+
//! Unit struct constructors used as the RHS of a `#[type_const]` associated
4+
//! const used to ICE during normalization because they were lowered as
5+
//! `Const::new_unevaluated` with a Ctor def_id. Fixed by adding proper const
6+
//! constructor support that produces a concrete ValTree value instead.
7+
8+
//@ check-pass
9+
10+
#![feature(min_generic_const_args, adt_const_params)]
11+
#![expect(incomplete_features)]
12+
13+
use std::marker::ConstParamTy;
14+
15+
#[derive(ConstParamTy, PartialEq, Eq)]
16+
struct S;
17+
18+
impl S {
19+
#[type_const]
20+
const N: S = S;
21+
}
22+
23+
#[derive(ConstParamTy, PartialEq, Eq)]
24+
enum E {
25+
V,
26+
}
27+
28+
impl E {
29+
#[type_const]
30+
const M: E = { E::V };
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)