Skip to content
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

regression: proc-macro to_string change for "invisible" delimiters #97608

Closed
Mark-Simulacrum opened this issue Jun 1, 2022 · 11 comments · Fixed by #97636
Closed

regression: proc-macro to_string change for "invisible" delimiters #97608

Mark-Simulacrum opened this issue Jun 1, 2022 · 11 comments · Fixed by #97636
Labels
P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

https://crater-reports.s3.amazonaws.com/beta-1.62-1/beta-2022-05-20/gh/Patryk27.lxd-snapper/log.txt

Seems to be due to an older(?) version of indoc, possibly already fixed, but wanted to file in case there was an unintentional change on our end.

cc @dtolnay (indoc-impl author, I believe)

dtolnay/indoc@29e8c96 may have been related to this as well.

@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Jun 1, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.62.0 milestone Jun 1, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 1, 2022
@dtolnay dtolnay changed the title regression: proc-macro tokenization change for literals? regression: proc-macro to_string change for "invisible" delimiters Jun 1, 2022
@dtolnay
Copy link
Member

dtolnay commented Jun 1, 2022

That repo's Cargo.lock is set to indoc 1.0.3. This error is fixed in indoc 1.0.5 and a better fix (which you linked) in 1.0.6.

It's not clear to me that @nnethercote's #96682 was intended to apply to proc_macro's Display impls, as opposed to only rustc_ast_pretty and various places that tokens get shown in diagnostics, and whether that should've had a team FCP.

@nnethercote
Copy link
Contributor

cc @petrochenkov, who knows more about all this stuff than I do.

@dtolnay
Copy link
Member

dtolnay commented Jun 1, 2022

@rust-lang/libs-api, @rust-lang/compiler:
#96682 has the effect (among other things) that proc_macro::TokenTree's Display impl is going to put /*«*/ /*»*/ around tokens of type TokenTree::Group with delimiter=Delimiter::None. #97076 has a minimal example.

This broke a small number of macros which involved manipulating the Display representation of tokens. One example is this code in scale-info which is a primitive way of turning a type into a pleasantly-spaced type name string, like ( bool , bool ) -> "(bool, bool)":

Another example is this code in indoc for categorizing kinds of literals:

I don't necessarily object to the change but it's worth being aware that this has made the strings /*«*/ and /*»*/ part of the API of proc_macro whether we like it or not and crates are going to start parsing exactly those strings, so any future change to how Delimiter::None appears in Display output is going to become even more disruptive.

If someone feels inclined to run a post-hoc FCP we may have time for one before 1.62 (4 weeks from now) or we can revert and take longer.

@nnethercote
Copy link
Contributor

My inclination is to back out #96682 and move on, but @petrochenkov may have a better idea.

@petrochenkov
Copy link
Contributor

Yes, reverting #96682 should be fine.

@apiraino
Copy link
Contributor

apiraino commented Jun 1, 2022

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 1, 2022
@nnethercote
Copy link
Contributor

#97636 is open for the reversion.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 2, 2022
Revert rust-lang#96682.

The change was "Show invisible delimiters (within comments) when pretty
printing". It's useful to show these delimiters, but is a breaking
change for some proc macros.

Fixes rust-lang#97608.

r? `@petrochenkov`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 2, 2022
Revert rust-lang#96682.

The change was "Show invisible delimiters (within comments) when pretty
printing". It's useful to show these delimiters, but is a breaking
change for some proc macros.

Fixes rust-lang#97608.

r? ``@petrochenkov``
@bors bors closed this as completed in 77e1069 Jun 2, 2022
@wesleywiser
Copy link
Member

Re-opening to track the beta backport.

@wesleywiser wesleywiser reopened this Jun 2, 2022
@the8472
Copy link
Member

the8472 commented Jun 3, 2022

This broke a small number of macros which involved manipulating the Display representation of tokens.

We recently discussed Display stability in t-libs. One idea is to use specialization to have a ToString impl that's separate from Display. If the compiler crates emitting those macros could make use of specialization then we could point user crates to use ToString instead while leaving the delimiters in Display.

ehuss pushed a commit to ehuss/rust that referenced this issue Jun 24, 2022
Revert rust-lang#96682.

The change was "Show invisible delimiters (within comments) when pretty
printing". It's useful to show these delimiters, but is a breaking
change for some proc macros.

Fixes rust-lang#97608.

r? ``@petrochenkov``
@pietroalbini
Copy link
Member

Being backported in #98440.

@workingjubilee
Copy link
Member

This seems to have been fully resolved for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants