Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkin
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
This commit is contained in:
commit
eb3e9c1f45
47 changed files with 127 additions and 104 deletions
|
@ -90,7 +90,7 @@ fn convert_to_hir_projections_and_truncate_for_capture(
|
|||
ProjectionElem::Deref => HirProjectionKind::Deref,
|
||||
ProjectionElem::Field(field, _) => {
|
||||
let variant = variant.unwrap_or(FIRST_VARIANT);
|
||||
HirProjectionKind::Field(field.index() as u32, variant)
|
||||
HirProjectionKind::Field(*field, variant)
|
||||
}
|
||||
ProjectionElem::Downcast(.., idx) => {
|
||||
// We don't expect to see multi-variant enums here, as earlier
|
||||
|
|
|
@ -733,7 +733,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
hir::ExprKind::Field(ref source, ..) => ExprKind::Field {
|
||||
lhs: self.mirror_expr(source),
|
||||
variant_index: FIRST_VARIANT,
|
||||
name: FieldIdx::new(self.typeck_results.field_index(expr.hir_id)),
|
||||
name: self.typeck_results.field_index(expr.hir_id),
|
||||
},
|
||||
hir::ExprKind::Cast(ref source, ref cast_ty) => {
|
||||
// Check for a user-given type annotation on this `cast`
|
||||
|
@ -1053,7 +1053,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
HirProjectionKind::Field(field, variant_index) => ExprKind::Field {
|
||||
lhs: self.thir.exprs.push(captured_place_expr),
|
||||
variant_index,
|
||||
name: FieldIdx::new(field as usize),
|
||||
name: field,
|
||||
},
|
||||
HirProjectionKind::Index | HirProjectionKind::Subslice => {
|
||||
// We don't capture these projections, so we can ignore them here
|
||||
|
@ -1107,7 +1107,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
fields
|
||||
.iter()
|
||||
.map(|field| FieldExpr {
|
||||
name: FieldIdx::new(self.typeck_results.field_index(field.hir_id)),
|
||||
name: self.typeck_results.field_index(field.hir_id),
|
||||
expr: self.mirror_expr(field.expr),
|
||||
})
|
||||
.collect()
|
||||
|
|
|
@ -357,7 +357,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
let subpatterns = fields
|
||||
.iter()
|
||||
.map(|field| FieldPat {
|
||||
field: FieldIdx::new(self.typeck_results.field_index(field.hir_id)),
|
||||
field: self.typeck_results.field_index(field.hir_id),
|
||||
pattern: self.lower_pattern(&field.pat),
|
||||
})
|
||||
.collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue