-
Couldn't load subscription status.
- Fork 13.9k
Pretty print break and continue without redundant space #91568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
|
@bors r+ |
|
📌 Commit abb8893 has been approved by |
Pretty print break and continue without redundant space
**Repro:**
```rust
macro_rules! m {
($e:expr) => { stringify!($e) };
}
fn main() {
println!("{:?}", m!(loop { break; }));
println!("{:?}", m!(loop { break 'a; }));
println!("{:?}", m!(loop { break false; }));
}
```
**Before:**
- `"loop { break ; }"`
- `"loop { break 'a ; }"`
- `"loop { break false ; }"`
**After:**
- `"loop { break; }"`
- `"loop { break 'a; }"`
- `"loop { break false; }"`
<br>
Notice that `return` and `yield` already follow the same approach as this PR of printing the space *before* each additional piece following the keyword, rather than *after* each thing.
https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_ast_pretty/src/pprust/state.rs#L2148-L2154
https://github.com/rust-lang/rust/blob/772d51f887fa407216860bf8ecf3f1a32fb795b4/compiler/rustc_ast_pretty/src/pprust/state.rs#L2221-L2228
|
☔ The latest upstream changes (presumably #91665) made this pull request unmergeable. Please resolve the merge conflicts. |
|
|
@bors r=nagisa |
|
📌 Commit f0f7b8d has been approved by |
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#91245 (suggest casting between i/u32 and char) - rust-lang#91337 (Add a suggestion if `macro_rules` is misspelled) - rust-lang#91534 (Make rustdoc headings black, and markdown blue) - rust-lang#91637 (Add test for packed drops in generators) - rust-lang#91667 (Fix indent of itemTypes in search.js) Failed merges: - rust-lang#91568 (Pretty print break and continue without redundant space) r? `@ghost` `@rustbot` modify labels: rollup
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#91042 (Use Vec extend instead of repeated pushes on several places) - rust-lang#91476 (Improve 'cannot contain emoji' error.) - rust-lang#91568 (Pretty print break and continue without redundant space) - rust-lang#91645 (Implement `core::future::join!`) - rust-lang#91666 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…acrum Add a test suite for stringify macro This attempts to cover the behavior of `stringify!` on various interpolated syntax tree nodes. The pretty printer has a history of unsightly whitespace (double spaces, missing spaces, spaces where there shouldn't be spaces) — rust-lang#91437, rust-lang#91562, rust-lang#91568. There are several such issues left; the test cases that I consider to be currently behaving incorrectly are marked with `// FIXME` in the PR.
…acrum Add a test suite for stringify macro This attempts to cover the behavior of `stringify!` on various interpolated syntax tree nodes. The pretty printer has a history of unsightly whitespace (double spaces, missing spaces, spaces where there shouldn't be spaces) — rust-lang#91437, rust-lang#91562, rust-lang#91568. There are several such issues left; the test cases that I consider to be currently behaving incorrectly are marked with `// FIXME` in the PR.
Repro:
Before:
"loop { break ; }""loop { break 'a ; }""loop { break false ; }"After:
"loop { break; }""loop { break 'a; }""loop { break false; }"Notice that
returnandyieldalready follow the same approach as this PR of printing the space before each additional piece following the keyword, rather than after each thing.rust/compiler/rustc_ast_pretty/src/pprust/state.rs
Lines 2148 to 2154 in 772d51f
rust/compiler/rustc_ast_pretty/src/pprust/state.rs
Lines 2221 to 2228 in 772d51f