ast/hir: Rename field-related structures

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

Also rename visiting and other methods working on them.
This commit is contained in:
Vadim Petrochenkov
2021-03-16 00:36:07 +03:00
parent 195ad4830e
commit b25d3ba781
57 changed files with 313 additions and 301 deletions

View File

@@ -647,7 +647,7 @@ impl Pat {
/// are treated the same as `x: x, y: ref y, z: ref mut z`,
/// except when `is_shorthand` is true.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct FieldPat {
pub struct PatField {
/// The identifier for the field.
pub ident: Ident,
/// The pattern the field is destructured to.
@@ -692,7 +692,7 @@ pub enum PatKind {
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
/// The `bool` is `true` in the presence of a `..`.
Struct(Path, Vec<FieldPat>, /* recovered */ bool),
Struct(Path, Vec<PatField>, /* recovered */ bool),
/// A tuple struct/variant pattern (`Variant(x, y, .., z)`).
TupleStruct(Path, Vec<P<Pat>>),
@@ -1027,9 +1027,9 @@ pub struct Arm {
pub is_placeholder: bool,
}
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
/// A single field in a struct expression, e.g. `x: value` and `y` in `Foo { x: value, y }`.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct Field {
pub struct ExprField {
pub attrs: AttrVec,
pub id: NodeId,
pub span: Span,
@@ -1369,7 +1369,7 @@ pub enum ExprKind {
/// A struct literal expression.
///
/// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. rest}`.
Struct(Path, Vec<Field>, StructRest),
Struct(Path, Vec<ExprField>, StructRest),
/// An array literal constructed from one repeated element.
///
@@ -2519,11 +2519,11 @@ impl VisibilityKind {
}
}
/// Field of a struct.
/// Field definition in a struct, variant or union.
///
/// E.g., `bar: usize` as in `struct Foo { bar: usize }`.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct StructField {
pub struct FieldDef {
pub attrs: Vec<Attribute>,
pub id: NodeId,
pub span: Span,
@@ -2540,11 +2540,11 @@ pub enum VariantData {
/// Struct variant.
///
/// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
Struct(Vec<StructField>, bool),
Struct(Vec<FieldDef>, bool),
/// Tuple variant.
///
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
Tuple(Vec<StructField>, NodeId),
Tuple(Vec<FieldDef>, NodeId),
/// Unit variant.
///
/// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
@@ -2553,7 +2553,7 @@ pub enum VariantData {
impl VariantData {
/// Return the fields of this variant.
pub fn fields(&self) -> &[StructField] {
pub fn fields(&self) -> &[FieldDef] {
match *self {
VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, _) => fields,
_ => &[],