]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-Simulacrum
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 7 Dec 2021 10:05:06 +0000 (11:05 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Dec 2021 10:05:06 +0000 (11:05 +0100)
commitb2dcfddb24df78ec660b498ddf780550ba052119
tree68734e75c6c9c691b0aee3a678eac6a9bc7899f8
parent1c2fba65406e1d901194ec4c2c3162ba10e45f5b
parent33c29a3ad36621bf812fd8af0adceb16188f3624
Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-Simulacrum

Pretty print async block without redundant space

**Repro:**

```rust
macro_rules! m {
    ($e:expr) => { stringify!($e) };
}
fn main() {
    println!("{:?}", m!(async {}));
}
```

**Before:** <code>"async&nbsp;&nbsp;{}"</code>
**After:** `"async {}"`

<br>

In this function:

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2049-L2051

the `print_capture_clause` and `word_nbsp`/`word_space` calls already put a space after the `async` and `move` keywords being printed. The extra `self.s.space()` call removed by this PR resulted in the redundant double space.

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2640-L2645

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L34-L37

https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L5-L8
compiler/rustc_ast_pretty/src/pprust/state.rs