diff options
| author | bors <bors@rust-lang.org> | 2023-08-24 12:52:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-24 12:52:35 +0000 |
| commit | 18be2728bd0d59c8fc74311de365a52a2d5e3eee (patch) | |
| tree | 5db356f964085a5d2901047315404a8b17a4fa44 /src | |
| parent | 8a6b67f988965f7e0ea5d4db6a56b3c195f723f4 (diff) | |
| parent | 868706d9b50ddf27995a9ee4d863e163b78b7365 (diff) | |
Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkov
Parse unnamed fields and anonymous structs or unions (no-recovery) It is part of #114782 which implements #49804. Only parse anonymous structs or unions in struct field definition positions. r? `@petrochenkov`
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rustfmt/src/types.rs | 2 | ||||
| -rw-r--r-- | src/tools/rustfmt/tests/target/anonymous-types.rs | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index 18a08f17ba0..5e8edd8f8bf 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -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) } diff --git a/src/tools/rustfmt/tests/target/anonymous-types.rs b/src/tools/rustfmt/tests/target/anonymous-types.rs new file mode 100644 index 00000000000..8e08c314ed1 --- /dev/null +++ b/src/tools/rustfmt/tests/target/anonymous-types.rs @@ -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() {} |
