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:
parent
00b60cdd46
commit
cef3117302
@ -819,6 +819,8 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
|
||||
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)
|
||||
}
|
||||
|
19
tests/target/anonymous-types.rs
Normal file
19
tests/target/anonymous-types.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user