1
Fork 0

Use FieldIdx in various things related to aggregates

Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
This commit is contained in:
Scott McMurray 2023-04-01 20:11:38 -07:00
parent 480068c235
commit b5b6def021
13 changed files with 51 additions and 46 deletions

View file

@ -185,7 +185,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
},
ExprKind::Adt(box AdtExpr{ adt_def, variant_index, substs, fields, .. }) => {
let is_union = adt_def.is_union();
let active_field_index = is_union.then(|| fields[0].name.index());
let active_field_index = is_union.then(|| fields[0].name);
Ok(Rvalue::Aggregate(
Box::new(AggregateKind::Adt(adt_def.did(), *variant_index, substs, None, active_field_index)),