Skip to content

Commit

Permalink
pretty: print attrs in struct expr
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Feb 1, 2020
1 parent cdd41ea commit 103e87c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,12 +1751,15 @@ impl<'a> State<'a> {
attrs: &[Attribute],
) {
self.print_path(path, true, 0);
self.nbsp();
self.s.word("{");
self.print_inner_attributes_inline(attrs);
self.commasep_cmnt(
Consistent,
&fields[..],
|s, field| {
s.print_outer_attributes(&field.attrs);
s.space_if_not_bol();
s.ibox(INDENT_UNIT);
if !field.is_shorthand {
s.print_ident(field.ident);
Expand All @@ -1769,6 +1772,7 @@ impl<'a> State<'a> {
);
match *wth {
Some(ref expr) => {
self.space_if_not_bol();
self.ibox(INDENT_UNIT);
if !fields.is_empty() {
self.s.word(",");
Expand Down
16 changes: 16 additions & 0 deletions src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs
Original file line number Diff line number Diff line change
@@ -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,};

0 comments on commit 103e87c

Please sign in to comment.