diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-28 09:53:41 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-28 15:51:27 +1000 |
| commit | bb04e11e471b070770edaef785d766255688288d (patch) | |
| tree | b0fe696b93f60f0cc111b21523f40babc6ee4c89 /compiler/rustc_ast_pretty | |
| parent | 61a66b188c41353fefc4d8840c6113a89d0b8fe2 (diff) | |
| download | rust-bb04e11e471b070770edaef785d766255688288d.tar.gz rust-bb04e11e471b070770edaef785d766255688288d.zip | |
Inline and remove three pretty-printer methods.
They all have a single call site, aren't that big, and removing them avoids having to pass some `BoxMarker`s.
Diffstat (limited to 'compiler/rustc_ast_pretty')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/item.rs | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 35b16259a33..1e02ac8fd5d 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -439,18 +439,8 @@ impl<'a> State<'a> { self.print_generic_params(&generics.params); self.print_where_clause(&generics.where_clause); self.space(); - self.print_variants(&enum_definition.variants, span, cb, ib) - } - - fn print_variants( - &mut self, - variants: &[ast::Variant], - span: rustc_span::Span, - cb: BoxMarker, - ib: BoxMarker, - ) { self.bopen(ib); - for v in variants { + for v in enum_definition.variants.iter() { self.space_if_not_bol(); self.maybe_print_comment(v.span.lo()); self.print_outer_attributes(&v.attrs); @@ -460,7 +450,7 @@ impl<'a> State<'a> { self.end(ib); self.maybe_print_trailing_comment(v.span, None); } - let empty = variants.is_empty(); + let empty = enum_definition.variants.is_empty(); self.bclose(span, empty, cb) } @@ -485,35 +475,6 @@ impl<'a> State<'a> { } } - pub(crate) fn print_record_struct_body( - &mut self, - fields: &[ast::FieldDef], - span: rustc_span::Span, - cb: BoxMarker, - ib: BoxMarker, - ) { - self.nbsp(); - self.bopen(ib); - - let empty = fields.is_empty(); - if !empty { - self.hardbreak_if_not_bol(); - - for field in fields { - 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); - self.word(","); - } - } - - self.bclose(span, empty, cb); - } - fn print_struct( &mut self, struct_def: &ast::VariantData, @@ -547,7 +508,26 @@ impl<'a> State<'a> { } ast::VariantData::Struct { fields, .. } => { self.print_where_clause(&generics.where_clause); - self.print_record_struct_body(fields, span, cb, ib); + self.nbsp(); + self.bopen(ib); + + let empty = fields.is_empty(); + if !empty { + self.hardbreak_if_not_bol(); + + for field in fields { + 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); + self.word(","); + } + } + + self.bclose(span, empty, cb); } } } |
