Reorder ast::ItemKind::{Struct,Enum,Union} fields.

So they match the order of the parts in the source code, e.g.:
```
struct Foo<T, U> { t: T, u: U }
       <-><----> <------------>
       /   |       \
   ident generics  variant_data
```
This commit is contained in:
Nicholas Nethercote
2025-05-28 08:20:30 +10:00
parent c583fa6d84
commit 4c4a40f6df
20 changed files with 54 additions and 56 deletions

View File

@@ -1577,7 +1577,7 @@ impl<'a> Parser<'a> {
};
let enum_definition = EnumDef { variants: variants.into_iter().flatten().collect() };
Ok(ItemKind::Enum(ident, enum_definition, generics))
Ok(ItemKind::Enum(ident, generics, enum_definition))
}
fn parse_enum_variant(&mut self, span: Span) -> PResult<'a, Option<Variant>> {
@@ -1732,7 +1732,7 @@ impl<'a> Parser<'a> {
return Err(self.dcx().create_err(err));
};
Ok(ItemKind::Struct(ident, vdata, generics))
Ok(ItemKind::Struct(ident, generics, vdata))
}
/// Parses `union Foo { ... }`.
@@ -1764,7 +1764,7 @@ impl<'a> Parser<'a> {
return Err(err);
};
Ok(ItemKind::Union(ident, vdata, generics))
Ok(ItemKind::Union(ident, generics, vdata))
}
/// This function parses the fields of record structs: