1
Fork 0

Auto merge of #83188 - petrochenkov:field, r=lcnr

ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
This commit is contained in:
bors 2021-03-17 16:49:46 +00:00
commit b4adc21c4f
61 changed files with 358 additions and 326 deletions

View file

@ -1111,7 +1111,10 @@ impl<'thir, 'tcx> Cx<'thir, 'tcx> {
}
/// Converts a list of named fields (i.e., for struct-like struct/enum ADTs) into FieldExpr.
fn field_refs(&mut self, fields: &'tcx [hir::Field<'tcx>]) -> &'thir [FieldExpr<'thir, 'tcx>] {
fn field_refs(
&mut self,
fields: &'tcx [hir::ExprField<'tcx>],
) -> &'thir [FieldExpr<'thir, 'tcx>] {
self.arena.alloc_from_iter(fields.iter().map(|field| FieldExpr {
name: Field::new(self.tcx.field_index(field.hir_id, self.typeck_results)),
expr: self.mirror_expr(field.expr),