diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-03 00:09:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-03 00:09:12 +0200 |
| commit | f6d8977fbb7a97cb49220a7a9eaa7bd26ee0e4a6 (patch) | |
| tree | b5be94d7733634174c7080b778da84e216392c11 /src/libsyntax | |
| parent | 109b21f7b7ecd08f26449e384cf3d3e957f98f22 (diff) | |
| parent | d1c89d64bcc21e4f25ef89889048fe231dd7eabe (diff) | |
| download | rust-f6d8977fbb7a97cb49220a7a9eaa7bd26ee0e4a6.tar.gz rust-f6d8977fbb7a97cb49220a7a9eaa7bd26ee0e4a6.zip | |
Rollup merge of #63212 - Centril:param-attrs-pretty, r=davidtwco
Pretty print attributes in `print_arg` Fixes https://github.com/rust-lang/rust/issues/63210. cc https://github.com/rust-lang/rust/issues/60406 r? @petrochenkov
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3645ab88d55..07b1aef337f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2622,27 +2622,23 @@ impl<'a> State<'a> { self.s.word("<"); self.commasep(Inconsistent, &generic_params, |s, param| { + s.print_outer_attributes_inline(¶m.attrs); + match param.kind { ast::GenericParamKind::Lifetime => { - s.print_outer_attributes_inline(¶m.attrs); let lt = ast::Lifetime { id: param.id, ident: param.ident }; s.print_lifetime_bounds(lt, ¶m.bounds) } ast::GenericParamKind::Type { ref default } => { - s.print_outer_attributes_inline(¶m.attrs); s.print_ident(param.ident); s.print_type_bounds(":", ¶m.bounds); - match default { - Some(ref default) => { - s.s.space(); - s.word_space("="); - s.print_type(default) - } - _ => {} + if let Some(ref default) = default { + s.s.space(); + s.word_space("="); + s.print_type(default) } } ast::GenericParamKind::Const { ref ty } => { - s.print_outer_attributes_inline(¶m.attrs); s.word_space("const"); s.print_ident(param.ident); s.s.space(); @@ -2743,6 +2739,9 @@ impl<'a> State<'a> { crate fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) { self.ibox(INDENT_UNIT); + + self.print_outer_attributes_inline(&input.attrs); + match input.ty.node { ast::TyKind::Infer if is_closure => self.print_pat(&input.pat), _ => { |
