Skip to content

Commit de93434

Browse files
authored
Rollup merge of rust-lang#86358 - klensy:pp-loop, r=Mark-Simulacrum
fix pretty print for `loop`
2 parents 4afdef0 + ac72773 commit de93434

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,6 @@ impl<'a> State<'a> {
19541954
self.word_space(":");
19551955
}
19561956
self.head("loop");
1957-
self.s.space();
19581957
self.print_block_with_attrs(blk, attrs);
19591958
}
19601959
ast::ExprKind::Match(ref expr, ref arms) => {

compiler/rustc_hir_pretty/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,6 @@ impl<'a> State<'a> {
15391539
self.word_space(":");
15401540
}
15411541
self.head("loop");
1542-
self.s.space();
15431542
self.print_block(&blk);
15441543
}
15451544
hir::ExprKind::Match(ref expr, arms, _) => {

src/test/pretty/ast-stmt-expr-attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn syntax() {
3939
#![attr]
4040
};
4141
let _ =
42-
#[attr] loop {
42+
#[attr] loop {
4343
#![attr]
4444
};
4545
let _ =

src/test/pretty/hir-pretty-loop.pp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[prelude_import]
2+
use ::std::prelude::rust_2015::*;
3+
#[macro_use]
4+
extern crate std;
5+
// pretty-compare-only
6+
// pretty-mode:hir
7+
// pp-exact:hir-pretty-loop.pp
8+
9+
pub fn foo() { loop { break ; } }

src/test/pretty/hir-pretty-loop.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// pretty-compare-only
2+
// pretty-mode:hir
3+
// pp-exact:hir-pretty-loop.pp
4+
5+
pub fn foo(){
6+
loop{
7+
break;
8+
}
9+
}

src/test/pretty/stmt_expr_attributes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ fn _11() {
166166
#[rustc_dummy] for _ in 0..0 {
167167
#![rustc_dummy]
168168
};
169-
// FIXME: pp bug, two spaces after the loop
170169
let _ =
171-
#[rustc_dummy] loop {
170+
#[rustc_dummy] loop {
172171
#![rustc_dummy]
173172
};
174173
let _ =

0 commit comments

Comments
 (0)