Parse unnamed fields and anonymous structs or unions

Anonymous structs or unions are only allowed in struct field
definitions.

Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
This commit is contained in:
Frank King 2023-08-23 20:53:47 +08:00
parent 327903e669
commit af6a6a3c2c
2 changed files with 21 additions and 0 deletions

View File

@ -819,6 +819,8 @@ impl Rewrite for ast::Ty {
ast::TyKind::Tup(ref items) => {
rewrite_tuple(context, items.iter(), self.span, shape, items.len() == 1)
}
ast::TyKind::AnonStruct(_) => Some(context.snippet(self.span).to_owned()),
ast::TyKind::AnonUnion(_) => Some(context.snippet(self.span).to_owned()),
ast::TyKind::Path(ref q_self, ref path) => {
rewrite_path(context, PathContext::Type, q_self, path, shape)
}

View File

@ -0,0 +1,19 @@
// Test for issue 85480
// Pretty print anonymous struct and union types
// pp-exact
// pretty-compare-only
struct Foo {
_: union {
_: struct {
a: u8,
b: u16,
},
c: u32,
},
d: u64,
e: f32,
}
fn main() {}