Skip to content

Commit ac72773

Browse files
committed
fix pretty print for loop in mir and hir
1 parent 52b2286 commit ac72773

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
@@ -1950,7 +1950,6 @@ impl<'a> State<'a> {
19501950
self.word_space(":");
19511951
}
19521952
self.head("loop");
1953-
self.s.space();
19541953
self.print_block_with_attrs(blk, attrs);
19551954
}
19561955
ast::ExprKind::Match(ref expr, ref arms) => {

compiler/rustc_hir_pretty/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,6 @@ impl<'a> State<'a> {
15381538
self.word_space(":");
15391539
}
15401540
self.head("loop");
1541-
self.s.space();
15421541
self.print_block(&blk);
15431542
}
15441543
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
@@ -159,9 +159,8 @@ fn _11() {
159159
#[rustc_dummy] for _ in 0..0 {
160160
#![rustc_dummy]
161161
};
162-
// FIXME: pp bug, two spaces after the loop
163162
let _ =
164-
#[rustc_dummy] loop {
163+
#[rustc_dummy] loop {
165164
#![rustc_dummy]
166165
};
167166
let _ = #[rustc_dummy] match false { _ => (), };

0 commit comments

Comments
 (0)