diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-04-06 17:15:31 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-04-06 17:15:31 +0530 |
| commit | af7b00b68fc7960e98fb914be52d9a6a16fe2224 (patch) | |
| tree | 13260050b5b5463c491ae61c941f60477421fdc0 /src/libsyntax/print | |
| parent | 772c600d4d6f39daa6d07d1a60ee0df3d3426978 (diff) | |
| parent | 8fe4290f1cf87bf7b0a0661e6bbe84f3319e614d (diff) | |
Rollup merge of #32682 - petrochenkov:field3, r=Manishearth
The AST part of https://github.com/rust-lang/rust/pull/31937 Unlike HIR, AST still uses `Option` for field names because parser can't know field indexes reliably due to constructions like ``` struct S(#[cfg(false)] u8, u8); // The index of the second field changes from 1 during parsing to 0 after expansion. ``` and I wouldn't like to put the burden of renaming fields on expansion passes and syntax extensions. plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645 r? @Manishearth
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a8f28ed3d9e..e2b1d2f5e7a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1407,14 +1407,9 @@ impl<'a> State<'a> { self.commasep( Inconsistent, struct_def.fields(), |s, field| { - match field.node.kind { - ast::NamedField(..) => panic!("unexpected named field"), - ast::UnnamedField(ref vis) => { - s.print_visibility(vis)?; - s.maybe_print_comment(field.span.lo)?; - s.print_type(&field.node.ty) - } - } + s.print_visibility(&field.vis)?; + s.maybe_print_comment(field.span.lo)?; + s.print_type(&field.ty) } )?; self.pclose()?; @@ -1432,19 +1427,14 @@ impl<'a> State<'a> { self.hardbreak_if_not_bol()?; for field in struct_def.fields() { - match field.node.kind { - ast::UnnamedField(..) => panic!("unexpected unnamed field"), - ast::NamedField(ident, ref visibility) => { - self.hardbreak_if_not_bol()?; - self.maybe_print_comment(field.span.lo)?; - self.print_outer_attributes(&field.node.attrs)?; - self.print_visibility(visibility)?; - self.print_ident(ident)?; - self.word_nbsp(":")?; - self.print_type(&field.node.ty)?; - word(&mut self.s, ",")?; - } - } + self.hardbreak_if_not_bol()?; + self.maybe_print_comment(field.span.lo)?; + self.print_outer_attributes(&field.attrs)?; + self.print_visibility(&field.vis)?; + self.print_ident(field.ident.unwrap())?; + self.word_nbsp(":")?; + self.print_type(&field.ty)?; + word(&mut self.s, ",")?; } self.bclose(span) |
