-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve token stream pretty printing. #97340
Improve token stream pretty printing. #97340
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
@@ -636,7 +636,7 @@ fn test_item() { | |||
() => {}; | |||
} | |||
), | |||
"macro_rules! stringify { () => {} ; }", // FIXME | |||
"macro_rules! stringify { () => {}; }", // FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the FIXME for?
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::b
instead ofa :: b
.!
and(
, e.g.foo!()
instead offoo! ()
.!
and[
, e.g.#![...]
instead of#! [...]
.:
, e.g.a: u32
instead ofa : u32
.;
, e.g.struct A;
instead ofstruct A ;
.r? @petrochenkov