From 875cef0324877627f617ca0e6d929b97972e6be9 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 2 Aug 2019 08:36:08 +0200 Subject: [PATCH] Cleanup 'print_generic_params'. --- src/libsyntax/print/pprust.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 88ff6ee9071..8c4c90f2085 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2639,27 +2639,23 @@ fn print_explicit_self(&mut self, explicit_self: &ast::ExplicitSelf) { 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(); -- 2.44.0