From 00f0b0cd3ab667e151b8e4d06e314d3b40038495 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 1 Feb 2020 18:45:03 +0100 Subject: [PATCH] pretty: print attrs in struct expr --- src/librustc_ast_pretty/pprust.rs | 1 + .../issue-68710-field-attr-proc-mac-lost.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs diff --git a/src/librustc_ast_pretty/pprust.rs b/src/librustc_ast_pretty/pprust.rs index 761af72f95dd6..3cc67a7c82117 100644 --- a/src/librustc_ast_pretty/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -1749,6 +1749,7 @@ impl<'a> State<'a> { Consistent, &fields[..], |s, field| { + s.print_outer_attributes(&field.attrs); s.ibox(INDENT_UNIT); if !field.is_shorthand { s.print_ident(field.ident); diff --git a/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs new file mode 100644 index 0000000000000..643ca761aac32 --- /dev/null +++ b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs @@ -0,0 +1,16 @@ +// pp-exact + +fn main() { } + +struct C { + field: u8, +} + +#[allow()] +const C: C = + C{ + #[cfg(debug_assertions)] + field: 0, + + #[cfg(not (debug_assertions))] + field: 1,};