Improve token stream pretty printing.#97340
Improve token stream pretty printing.#97340nnethercote wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
Specifically: - No space before or after `::`, e.g. `a::b` instead of `a :: b`. - No space between `!` and `(`, e.g. `foo!()` instead of `foo! ()`. - No space between `!` and `[`, e.g. `#![...]` instead of `#! [...]`. - No space before `:`, e.g. `a: u32` instead of `a : u32`. - No space before `;`, e.g. `struct A;` instead of `struct A ;`.
1129138 to
20d4424
Compare
| } | ||
| ), | ||
| "macro_rules! stringify { () => {} ; }", // FIXME | ||
| "macro_rules! stringify { () => {}; }", // FIXME |
|
Originally spaces were always printed because proc macros worked through pretty-printing and reparsing, and spaces prevented tokens from being glued together and forming other tokens, like Then we started skipping some spaces to avoid breaking code (#63897). Eventually people just started skipping them to beautify the pretty-printed code, which is incorrect in theory. |
|
To keep documentation links working with #96724 it should be enough to elide spaces in cases Although |
Specifically:
::, e.g.a::binstead ofa :: b.!and(, e.g.foo!()instead offoo! ().!and[, e.g.#![...]instead of#! [...].:, e.g.a: u32instead ofa : u32.;, e.g.struct A;instead ofstruct A ;.r? @petrochenkov