diff options
| author | varkor <github@varkor.com> | 2018-05-26 19:16:21 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-06-20 12:21:08 +0100 |
| commit | 2c6ff2469a94e37b9605a43bc861de66830a94d4 (patch) | |
| tree | 36c1ad6aed0cceb2980e97878c48436fe2d9d757 /src/libsyntax/print/pprust.rs | |
| parent | fba1fe21084bf248334ad46b0b0a8c40a6d5ee7b (diff) | |
| download | rust-2c6ff2469a94e37b9605a43bc861de66830a94d4.tar.gz rust-2c6ff2469a94e37b9605a43bc861de66830a94d4.zip | |
Refactor ast::GenericParam as a struct
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a7a85a4c71f..1626135400d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2878,12 +2878,24 @@ impl<'a> State<'a> { self.s.word("<")?; self.commasep(Inconsistent, &generic_params, |s, param| { - match *param { - ast::GenericParamAST::Lifetime(ref lifetime_def) => { - s.print_outer_attributes_inline(&lifetime_def.attrs)?; - s.print_lifetime_bounds(&lifetime_def.lifetime, &lifetime_def.bounds) + match param.kind { + ast::GenericParamKindAST::Lifetime { ref bounds, ref lifetime } => { + s.print_outer_attributes_inline(¶m.attrs)?; + s.print_lifetime_bounds(lifetime, bounds) }, - ast::GenericParamAST::Type(ref ty_param) => s.print_ty_param(ty_param), + ast::GenericParamKindAST::Type { ref bounds, ref default } => { + s.print_outer_attributes_inline(¶m.attrs)?; + s.print_ident(param.ident)?; + s.print_bounds(":", bounds)?; + match default { + Some(ref default) => { + s.s.space()?; + s.word_space("=")?; + s.print_type(default) + } + _ => Ok(()) + } + } } })?; @@ -2891,20 +2903,6 @@ impl<'a> State<'a> { Ok(()) } - pub fn print_ty_param(&mut self, param: &ast::TyParam) -> io::Result<()> { - self.print_outer_attributes_inline(¶m.attrs)?; - self.print_ident(param.ident)?; - self.print_bounds(":", ¶m.bounds)?; - match param.default { - Some(ref default) => { - self.s.space()?; - self.word_space("=")?; - self.print_type(default) - } - _ => Ok(()) - } - } - pub fn print_where_clause(&mut self, where_clause: &ast::WhereClause) -> io::Result<()> { if where_clause.predicates.is_empty() { |
