Skip to content

Commit e1f55b0

Browse files
committed
HIR ty lowering stuff
1 parent 3c91986 commit e1f55b0

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,21 +2264,23 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
22642264
.unwrap_or_else(|guar| Const::new_error(tcx, guar))
22652265
}
22662266
hir::ConstArgKind::Struct(qpath, inits) => {
2267-
self.lower_struct_expr_const_arg(hir_id, qpath, inits, const_arg.span())
2267+
self.lower_const_arg_struct(hir_id, qpath, inits, const_arg.span())
22682268
}
2269-
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon),
2269+
hir::ConstArgKind::Anon(anon) => self.lower_const_arg_anon(anon),
22702270
hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span),
22712271
hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e),
22722272
}
22732273
}
22742274

2275-
fn lower_struct_expr_const_arg(
2275+
fn lower_const_arg_struct(
22762276
&self,
22772277
hir_id: HirId,
22782278
qpath: hir::QPath<'tcx>,
22792279
inits: &'tcx [&'tcx hir::ConstArgExprField<'tcx>],
22802280
span: Span,
22812281
) -> Const<'tcx> {
2282+
// FIXME(mgca): try to deduplicate this function with
2283+
// the equivalent HIR typeck logic.
22822284
let tcx = self.tcx();
22832285

22842286
let non_adt_or_variant_res = || {
@@ -2330,7 +2332,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23302332
.fields
23312333
.iter()
23322334
.map(|field_def| {
2333-
// FIXME(mgca): we aren't really handling privacy or stability at all but we should
2335+
// FIXME(mgca): we aren't really handling privacy, stability,
2336+
// or macro hygeniene but we should.
23342337
let mut init_expr =
23352338
inits.iter().filter(|init_expr| init_expr.field.name == field_def.name);
23362339

@@ -2477,7 +2480,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24772480

24782481
/// Literals are eagerly converted to a constant, everything else becomes `Unevaluated`.
24792482
#[instrument(skip(self), level = "debug")]
2480-
fn lower_anon_const(&self, anon: &AnonConst) -> Const<'tcx> {
2483+
fn lower_const_arg_anon(&self, anon: &AnonConst) -> Const<'tcx> {
24812484
let tcx = self.tcx();
24822485

24832486
let expr = &tcx.hir_body(anon.body).value;

tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#![expect(incomplete_features)]
33
#![crate_type = "lib"]
44

5+
// Miscellaneous assortment of invalid cases of directly represented
6+
// `ConstArgKind::Struct`'s under mgca.
7+
58
#[derive(Eq, PartialEq, std::marker::ConstParamTy)]
69
struct Foo<T> { field: T }
710

tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ check-pass
2-
// This should error
2+
// FIXME(mgca): This should error
33

44
#![feature(min_generic_const_args, adt_const_params)]
55
#![expect(incomplete_features)]

0 commit comments

Comments
 (0)