Rollup merge of #92412 - dtolnay:tryspace, r=Mark-Simulacrum

Fix double space in pretty printed TryBlock

Follow-up to #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:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L654-L664)

so doing `head` followed by `space` resulted in a double space:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L2241-L2242)
This commit is contained in:
Matthias Krüger 2022-01-01 10:48:55 +01:00 committed by GitHub
commit 682b4cbc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 2 deletions

View File

@ -2241,7 +2241,6 @@ impl<'a> State<'a> {
}
ast::ExprKind::TryBlock(ref blk) => {
self.head("try");
self.space();
self.print_block_with_attrs(blk, attrs)
}
ast::ExprKind::Err => {

View File

@ -256,7 +256,7 @@ fn test_expr() {
assert_eq!(stringify_expr!(expr.await), "expr.await");
// ExprKind::TryBlock
assert_eq!(stringify_expr!(try {}), "try {}"); // FIXME
assert_eq!(stringify_expr!(try {}), "try {}");
// ExprKind::Assign
assert_eq!(stringify_expr!(expr = true), "expr = true");