diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-24 00:06:58 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-24 12:10:16 +0300 |
| commit | c667c2fc0896b2a58a363d2c535881e5b983857a (patch) | |
| tree | 4116c0d210c4535f319e4c5f1ae483dabe5e9373 /src/libsyntax | |
| parent | 5c3d1e5d76fdc6d9f40ab13a6a342e1f7ceb4f17 (diff) | |
| download | rust-c667c2fc0896b2a58a363d2c535881e5b983857a.tar.gz rust-c667c2fc0896b2a58a363d2c535881e5b983857a.zip | |
Remove methods is_struct/is_tuple/is_unit from VariantData
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 27 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 73 |
2 files changed, 38 insertions, 62 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c64ffb1232f..bcc8fdf8cd4 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2155,33 +2155,6 @@ impl VariantData { VariantData::Tuple(_, id) | VariantData::Unit(id) => Some(id), } } - - /// Does this `VariantData` represent a `Struct`-struct/variant? - pub fn is_struct(&self) -> bool { - if let VariantData::Struct(..) = *self { - true - } else { - false - } - } - - /// Does this `VariantData` represent a tuple struct/variant? - pub fn is_tuple(&self) -> bool { - if let VariantData::Tuple(..) = *self { - true - } else { - false - } - } - - /// Does this `VariantData` represent a unit struct/variant? - pub fn is_unit(&self) -> bool { - if let VariantData::Unit(..) = *self { - true - } else { - false - } - } } /// An item. diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 946fdc0c469..f5a9aded845 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1550,44 +1550,47 @@ impl<'a> State<'a> { print_finalizer: bool) -> io::Result<()> { self.print_ident(ident)?; self.print_generic_params(&generics.params)?; - if !struct_def.is_struct() { - if struct_def.is_tuple() { - self.popen()?; - self.commasep( - Inconsistent, struct_def.fields(), - |s, field| { - s.maybe_print_comment(field.span.lo())?; - s.print_outer_attributes(&field.attrs)?; - s.print_visibility(&field.vis)?; - s.print_type(&field.ty) - } - )?; - self.pclose()?; - } - self.print_where_clause(&generics.where_clause)?; - if print_finalizer { - self.s.word(";")?; + match struct_def { + ast::VariantData::Tuple(..) | ast::VariantData::Unit(..) => { + if let ast::VariantData::Tuple(..) = struct_def { + self.popen()?; + self.commasep( + Inconsistent, struct_def.fields(), + |s, field| { + s.maybe_print_comment(field.span.lo())?; + s.print_outer_attributes(&field.attrs)?; + s.print_visibility(&field.vis)?; + s.print_type(&field.ty) + } + )?; + self.pclose()?; + } + self.print_where_clause(&generics.where_clause)?; + if print_finalizer { + self.s.word(";")?; + } + self.end()?; + self.end() // close the outer-box } - self.end()?; - self.end() // close the outer-box - } else { - self.print_where_clause(&generics.where_clause)?; - self.nbsp()?; - self.bopen()?; - self.hardbreak_if_not_bol()?; - - for field in struct_def.fields() { + ast::VariantData::Struct(..) => { + self.print_where_clause(&generics.where_clause)?; + self.nbsp()?; + self.bopen()?; 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.s.word(",")?; - } - self.bclose(span) + for field in struct_def.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.s.word(",")?; + } + + self.bclose(span) + } } } |
