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:
commit
b4adc21c4f
61 changed files with 358 additions and 326 deletions
|
@ -1158,7 +1158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expr: &hir::Expr<'_>,
|
||||
expected: Expectation<'tcx>,
|
||||
qpath: &QPath<'_>,
|
||||
fields: &'tcx [hir::Field<'tcx>],
|
||||
fields: &'tcx [hir::ExprField<'tcx>],
|
||||
base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>,
|
||||
) -> Ty<'tcx> {
|
||||
// Find the relevant variant
|
||||
|
@ -1231,7 +1231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expr_id: hir::HirId,
|
||||
span: Span,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
ast_fields: &'tcx [hir::Field<'tcx>],
|
||||
ast_fields: &'tcx [hir::ExprField<'tcx>],
|
||||
check_completeness: bool,
|
||||
) -> bool {
|
||||
let tcx = self.tcx;
|
||||
|
@ -1320,7 +1320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
fn check_struct_fields_on_error(
|
||||
&self,
|
||||
fields: &'tcx [hir::Field<'tcx>],
|
||||
fields: &'tcx [hir::ExprField<'tcx>],
|
||||
base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>,
|
||||
) {
|
||||
for field in fields {
|
||||
|
@ -1411,8 +1411,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
field: &hir::Field<'_>,
|
||||
skip_fields: &[hir::Field<'_>],
|
||||
field: &hir::ExprField<'_>,
|
||||
skip_fields: &[hir::ExprField<'_>],
|
||||
kind_name: &str,
|
||||
ty_span: Span,
|
||||
) {
|
||||
|
|
|
@ -680,7 +680,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
pat: &'tcx Pat<'tcx>,
|
||||
qpath: &hir::QPath<'_>,
|
||||
fields: &'tcx [hir::FieldPat<'tcx>],
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
etc: bool,
|
||||
expected: Ty<'tcx>,
|
||||
def_bm: BindingMode,
|
||||
|
@ -1151,7 +1151,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
adt_ty: Ty<'tcx>,
|
||||
pat: &'tcx Pat<'tcx>,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
fields: &'tcx [hir::FieldPat<'tcx>],
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
etc: bool,
|
||||
def_bm: BindingMode,
|
||||
ti: TopInfo<'tcx>,
|
||||
|
@ -1291,7 +1291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
variant: &VariantDef,
|
||||
pat: &'_ Pat<'_>,
|
||||
fields: &[hir::FieldPat<'_>],
|
||||
fields: &[hir::PatField<'_>],
|
||||
) -> Option<DiagnosticBuilder<'_>> {
|
||||
// if this is a tuple struct, then all field names will be numbers
|
||||
// so if any fields in a struct pattern use shorthand syntax, they will
|
||||
|
@ -1446,7 +1446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
fn error_tuple_variant_as_struct_pat(
|
||||
&self,
|
||||
pat: &Pat<'_>,
|
||||
fields: &'tcx [hir::FieldPat<'tcx>],
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
variant: &ty::VariantDef,
|
||||
) -> Option<DiagnosticBuilder<'tcx>> {
|
||||
if let (CtorKind::Fn, PatKind::Struct(qpath, ..)) = (variant.ctor_kind, &pat.kind) {
|
||||
|
@ -1484,7 +1484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
fn get_suggested_tuple_struct_pattern(
|
||||
&self,
|
||||
fields: &[hir::FieldPat<'_>],
|
||||
fields: &[hir::PatField<'_>],
|
||||
variant: &VariantDef,
|
||||
) -> String {
|
||||
let variant_field_idents = variant.fields.iter().map(|f| f.ident).collect::<Vec<Ident>>();
|
||||
|
@ -1528,7 +1528,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
fn error_no_accessible_fields(
|
||||
&self,
|
||||
pat: &Pat<'_>,
|
||||
fields: &'tcx [hir::FieldPat<'tcx>],
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = self
|
||||
.tcx
|
||||
|
@ -1574,7 +1574,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
pat: &Pat<'_>,
|
||||
unmentioned_fields: &[(&ty::FieldDef, Ident)],
|
||||
fields: &'tcx [hir::FieldPat<'tcx>],
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let field_names = if unmentioned_fields.len() == 1 {
|
||||
format!("field `{}`", unmentioned_fields[0].1)
|
||||
|
|
|
@ -456,7 +456,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
|
||||
fn walk_struct_expr(
|
||||
&mut self,
|
||||
fields: &[hir::Field<'_>],
|
||||
fields: &[hir::ExprField<'_>],
|
||||
opt_with: &Option<&'hir hir::Expr<'_>>,
|
||||
) {
|
||||
// Consume the expressions supplying values for each field.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue