Skip to content

Commit 682b4cb

Browse files
authored
Rollup merge of rust-lang#92412 - dtolnay:tryspace, r=Mark-Simulacrum
Fix double space in pretty printed TryBlock Follow-up to rust-lang#92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(try {})); } ``` Before:&ensp;<code>try&nbsp;&nbsp;{}</code> After:&ensp;<code>try&nbsp;{}</code> The `head` helper already appends a space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L654-L664 so doing `head` followed by `space` resulted in a double space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L2241-L2242
2 parents a6e4d68 + 2f25a4a commit 682b4cb

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,6 @@ impl<'a> State<'a> {
22412241
}
22422242
ast::ExprKind::TryBlock(ref blk) => {
22432243
self.head("try");
2244-
self.space();
22452244
self.print_block_with_attrs(blk, attrs)
22462245
}
22472246
ast::ExprKind::Err => {

src/test/ui/macros/stringify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn test_expr() {
256256
assert_eq!(stringify_expr!(expr.await), "expr.await");
257257

258258
// ExprKind::TryBlock
259-
assert_eq!(stringify_expr!(try {}), "try {}"); // FIXME
259+
assert_eq!(stringify_expr!(try {}), "try {}");
260260

261261
// ExprKind::Assign
262262
assert_eq!(stringify_expr!(expr = true), "expr = true");

0 commit comments

Comments
 (0)