Skip to content

Commit cef6894

Browse files
committed
Auto merge of #68737 - Centril:fix-68710, r=petrochenkov
pretty: print attrs in struct expr Fixes #68710 by printing the attributes on struct expression fields. r? @petrochenkov cc @dtolnay
2 parents 0cbcb17 + 00f0b0c commit cef6894

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Diff for: src/librustc_ast_pretty/pprust.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,7 @@ impl<'a> State<'a> {
17491749
Consistent,
17501750
&fields[..],
17511751
|s, field| {
1752+
s.print_outer_attributes(&field.attrs);
17521753
s.ibox(INDENT_UNIT);
17531754
if !field.is_shorthand {
17541755
s.print_ident(field.ident);
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// pp-exact
2+
3+
fn main() { }
4+
5+
struct C {
6+
field: u8,
7+
}
8+
9+
#[allow()]
10+
const C: C =
11+
C{
12+
#[cfg(debug_assertions)]
13+
field: 0,
14+
15+
#[cfg(not (debug_assertions))]
16+
field: 1,};

0 commit comments

Comments
 (0)