1
Fork 0

Lowering field access for anonymous adts

This commit is contained in:
Frank King 2024-01-04 21:45:06 +08:00
parent 36d7e7fd3f
commit 0c0df4efe0
18 changed files with 391 additions and 71 deletions

View file

@ -734,11 +734,21 @@ impl<'tcx> Cx<'tcx> {
});
ExprKind::Loop { body }
}
hir::ExprKind::Field(source, ..) => ExprKind::Field {
lhs: self.mirror_expr(source),
variant_index: FIRST_VARIANT,
name: self.typeck_results.field_index(expr.hir_id),
},
hir::ExprKind::Field(source, ..) => {
let mut kind = ExprKind::Field {
lhs: self.mirror_expr(source),
variant_index: FIRST_VARIANT,
name: self.typeck_results.field_index(expr.hir_id),
};
let nested_field_tys_and_indices =
self.typeck_results.nested_field_tys_and_indices(expr.hir_id);
for &(ty, idx) in nested_field_tys_and_indices {
let expr = Expr { temp_lifetime, ty, span: source.span, kind };
let lhs = self.thir.exprs.push(expr);
kind = ExprKind::Field { lhs, variant_index: FIRST_VARIANT, name: idx };
}
kind
}
hir::ExprKind::Cast(source, cast_ty) => {
// Check for a user-given type annotation on this `cast`
let user_provided_types = self.typeck_results.user_provided_types();