]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_ast_pretty/src/pprust/state.rs
RustWrapper: simplify removing attributes
[rust.git] / compiler / rustc_ast_pretty / src / pprust / state.rs
index 0d5ce07c6ca1101e73307e36e874d37b4fcb6402..91fa4595241dc764c31d291769b0fbb4f196b659 100644 (file)
@@ -2241,7 +2241,6 @@ fn print_expr_outer_attr_style(&mut self, expr: &ast::Expr, is_inline: bool) {
             }
             ast::ExprKind::TryBlock(ref blk) => {
                 self.head("try");
-                self.space();
                 self.print_block_with_attrs(blk, attrs)
             }
             ast::ExprKind::Err => {
@@ -2462,7 +2461,11 @@ fn print_qpath(&mut self, path: &ast::Path, qself: &ast::QSelf, colons_before_pa
                     self.print_path(path, true, 0);
                 }
                 self.nbsp();
-                self.word_space("{");
+                self.word("{");
+                let empty = fields.is_empty() && !etc;
+                if !empty {
+                    self.space();
+                }
                 self.commasep_cmnt(
                     Consistent,
                     &fields,
@@ -2483,7 +2486,9 @@ fn print_qpath(&mut self, path: &ast::Path, qself: &ast::QSelf, colons_before_pa
                     }
                     self.word("..");
                 }
-                self.space();
+                if !empty {
+                    self.space();
+                }
                 self.word("}");
             }
             PatKind::Tuple(ref elts) => {
@@ -2517,7 +2522,6 @@ fn print_qpath(&mut self, path: &ast::Path, qself: &ast::QSelf, colons_before_pa
             PatKind::Range(ref begin, ref end, Spanned { node: ref end_kind, .. }) => {
                 if let Some(e) = begin {
                     self.print_expr(e);
-                    self.space();
                 }
                 match *end_kind {
                     RangeEnd::Included(RangeSyntax::DotDotDot) => self.word("..."),