mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 22:53:28 +00:00
Pretty print break and continue without redundant space
This commit is contained in:
parent
e6b883c74f
commit
f0f7b8d44a
@ -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.word("break");
|
||||
self.space();
|
||||
if let Some(label) = opt_label {
|
||||
self.print_ident(label.ident);
|
||||
self.space();
|
||||
self.print_ident(label.ident);
|
||||
}
|
||||
if let Some(ref expr) = *opt_expr {
|
||||
self.print_expr_maybe_paren(expr, parser::PREC_JUMP);
|
||||
self.space();
|
||||
self.print_expr_maybe_paren(expr, parser::PREC_JUMP);
|
||||
}
|
||||
}
|
||||
ast::ExprKind::Continue(opt_label) => {
|
||||
self.word("continue");
|
||||
self.space();
|
||||
if let Some(label) = opt_label {
|
||||
self.space();
|
||||
self.print_ident(label.ident);
|
||||
self.space()
|
||||
}
|
||||
}
|
||||
ast::ExprKind::Ret(ref result) => {
|
||||
|
@ -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.word("break");
|
||||
self.space();
|
||||
if let Some(label) = destination.label {
|
||||
self.print_ident(label.ident);
|
||||
self.space();
|
||||
self.print_ident(label.ident);
|
||||
}
|
||||
if let Some(ref expr) = *opt_expr {
|
||||
self.print_expr_maybe_paren(expr, parser::PREC_JUMP);
|
||||
self.space();
|
||||
self.print_expr_maybe_paren(expr, parser::PREC_JUMP);
|
||||
}
|
||||
}
|
||||
hir::ExprKind::Continue(destination) => {
|
||||
self.word("continue");
|
||||
self.space();
|
||||
if let Some(label) = destination.label {
|
||||
self.space();
|
||||
self.print_ident(label.ident);
|
||||
self.space()
|
||||
}
|
||||
}
|
||||
hir::ExprKind::Ret(ref result) => {
|
||||
|
@ -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]);
|
||||
|
@ -6,4 +6,4 @@ extern crate std;
|
||||
// pretty-mode:hir
|
||||
// pp-exact:hir-pretty-loop.pp
|
||||
|
||||
pub fn foo() { loop { break ; } }
|
||||
pub fn foo() { loop { break; } }
|
||||
|
@ -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![];
|
||||
|
Loading…
Reference in New Issue
Block a user