diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 921ac785e815e..8f2a000fd43f3 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -2135,22 +2135,20 @@ impl<'a> State<'a> { ast::ExprKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, true), ast::ExprKind::Break(opt_label, ref opt_expr) => { self.s.word("break"); - self.s.space(); if let Some(label) = opt_label { - self.print_ident(label.ident); self.s.space(); + self.print_ident(label.ident); } if let Some(ref expr) = *opt_expr { - self.print_expr_maybe_paren(expr, parser::PREC_JUMP); self.s.space(); + self.print_expr_maybe_paren(expr, parser::PREC_JUMP); } } ast::ExprKind::Continue(opt_label) => { self.s.word("continue"); - self.s.space(); if let Some(label) = opt_label { + self.s.space(); self.print_ident(label.ident); - self.s.space() } } ast::ExprKind::Ret(ref result) => { diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 6b1ef598b4553..6cef1ee0c843a 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1543,22 +1543,20 @@ impl<'a> State<'a> { hir::ExprKind::Path(ref qpath) => self.print_qpath(qpath, true), hir::ExprKind::Break(destination, ref opt_expr) => { self.s.word("break"); - self.s.space(); if let Some(label) = destination.label { - self.print_ident(label.ident); self.s.space(); + self.print_ident(label.ident); } if let Some(ref expr) = *opt_expr { - self.print_expr_maybe_paren(expr, parser::PREC_JUMP); self.s.space(); + self.print_expr_maybe_paren(expr, parser::PREC_JUMP); } } hir::ExprKind::Continue(destination) => { self.s.word("continue"); - self.s.space(); if let Some(label) = destination.label { + self.s.space(); self.print_ident(label.ident); - self.s.space() } } hir::ExprKind::Ret(ref result) => { diff --git a/src/test/pretty/ast-stmt-expr-attr.rs b/src/test/pretty/ast-stmt-expr-attr.rs index c80bce2d140b9..e32f5ca24ea0f 100644 --- a/src/test/pretty/ast-stmt-expr-attr.rs +++ b/src/test/pretty/ast-stmt-expr-attr.rs @@ -110,8 +110,8 @@ fn syntax() { let _ = #[attr] &mut 0; let _ = #[attr] &#[attr] 0; let _ = #[attr] &mut #[attr] 0; - let _ = #[attr] break ; - let _ = #[attr] continue ; + let _ = #[attr] break; + let _ = #[attr] continue; let _ = #[attr] return; let _ = #[attr] foo!(); let _ = #[attr] foo!(#! [attr]); diff --git a/src/test/pretty/hir-pretty-loop.pp b/src/test/pretty/hir-pretty-loop.pp index 19b3a1775cf36..9b10fd86c4778 100644 --- a/src/test/pretty/hir-pretty-loop.pp +++ b/src/test/pretty/hir-pretty-loop.pp @@ -6,4 +6,4 @@ // pretty-mode:hir // pp-exact:hir-pretty-loop.pp -pub fn foo() { loop { break ; } } +pub fn foo() { loop { break; } } diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index 12204c8cd30ed..01533cd8107b0 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -229,9 +229,8 @@ fn _11() { let _ = #[rustc_dummy] &mut 0; let _ = #[rustc_dummy] &#[rustc_dummy] 0; let _ = #[rustc_dummy] &mut #[rustc_dummy] 0; - // FIXME: pp bug, extra space after keyword? - while false { let _ = #[rustc_dummy] continue ; } - while true { let _ = #[rustc_dummy] break ; } + while false { let _ = #[rustc_dummy] continue; } + while true { let _ = #[rustc_dummy] break; } || #[rustc_dummy] return; let _ = #[rustc_dummy] expr_mac!(); let _ = #[rustc_dummy] expr_mac![];