diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-29 00:26:55 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-29 00:26:55 +0900 |
| commit | de93434cf0db0c883c54645dd974ecfed24bcc26 (patch) | |
| tree | 231bd8fa471e7dc8a1513bd118de8e0afc3344c9 | |
| parent | 4afdef07d9edb6fab979b01f510a16ffc27a6ab6 (diff) | |
| parent | ac727732150ea338ea38727263b69a5cbadf13a9 (diff) | |
| download | rust-de93434cf0db0c883c54645dd974ecfed24bcc26.tar.gz rust-de93434cf0db0c883c54645dd974ecfed24bcc26.zip | |
Rollup merge of #86358 - klensy:pp-loop, r=Mark-Simulacrum
fix pretty print for `loop`
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir_pretty/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/pretty/ast-stmt-expr-attr.rs | 2 | ||||
| -rw-r--r-- | src/test/pretty/hir-pretty-loop.pp | 9 | ||||
| -rw-r--r-- | src/test/pretty/hir-pretty-loop.rs | 9 | ||||
| -rw-r--r-- | src/test/pretty/stmt_expr_attributes.rs | 3 |
6 files changed, 20 insertions, 5 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index ffee5cdc331..f14d8a693fd 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1954,7 +1954,6 @@ impl<'a> State<'a> { self.word_space(":"); } self.head("loop"); - self.s.space(); self.print_block_with_attrs(blk, attrs); } ast::ExprKind::Match(ref expr, ref arms) => { diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 3211c7c5621..5c1739b1ab9 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1539,7 +1539,6 @@ impl<'a> State<'a> { self.word_space(":"); } self.head("loop"); - self.s.space(); self.print_block(&blk); } hir::ExprKind::Match(ref expr, arms, _) => { diff --git a/src/test/pretty/ast-stmt-expr-attr.rs b/src/test/pretty/ast-stmt-expr-attr.rs index a32903a6409..32d1da390c5 100644 --- a/src/test/pretty/ast-stmt-expr-attr.rs +++ b/src/test/pretty/ast-stmt-expr-attr.rs @@ -39,7 +39,7 @@ fn syntax() { #![attr] }; let _ = - #[attr] loop { + #[attr] loop { #![attr] }; let _ = diff --git a/src/test/pretty/hir-pretty-loop.pp b/src/test/pretty/hir-pretty-loop.pp new file mode 100644 index 00000000000..19b3a1775cf --- /dev/null +++ b/src/test/pretty/hir-pretty-loop.pp @@ -0,0 +1,9 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// pretty-compare-only +// pretty-mode:hir +// pp-exact:hir-pretty-loop.pp + +pub fn foo() { loop { break ; } } diff --git a/src/test/pretty/hir-pretty-loop.rs b/src/test/pretty/hir-pretty-loop.rs new file mode 100644 index 00000000000..87a3ef8b8f9 --- /dev/null +++ b/src/test/pretty/hir-pretty-loop.rs @@ -0,0 +1,9 @@ +// pretty-compare-only +// pretty-mode:hir +// pp-exact:hir-pretty-loop.pp + +pub fn foo(){ + loop{ + break; + } +} diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index 231351433c8..e4a3acade87 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -166,9 +166,8 @@ fn _11() { #[rustc_dummy] for _ in 0..0 { #![rustc_dummy] }; - // FIXME: pp bug, two spaces after the loop let _ = - #[rustc_dummy] loop { + #[rustc_dummy] loop { #![rustc_dummy] }; let _ = |
