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

Show invisible delimeters (within comments) when pretty printing. #96682

Merged
merged 1 commit into from
May 5, 2022

Conversation

nnethercote
Copy link
Contributor

Because invisible syntax is really hard to work with!

r? @petrochenkov

@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 3, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 3, 2022
@nnethercote
Copy link
Contributor Author

nnethercote commented May 3, 2022

My general approach here was straightforward: to make the obvious change in rustc_ast_pretty and then change all affected tests to accept the new output, therefore assuming that the new test behaviour is reasonable.

The only libs change here is change to the text describing the None variant in https://doc.rust-lang.org/proc_macro/enum.Delimiter.html.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2022
@nnethercote
Copy link
Contributor Author

I have made the suggested changes. I was surprised to find that, once the print_mac_common change was made, the token_kind_to_string_ext change is no longer necessary because the code in that function handling invisible delimiters is unreachable, at least for the test suite.

@nnethercote
Copy link
Contributor Author

As a follow-on I am experimenting with returning Delimiter::Invisible tokens from TokenCursor. It's much nicer dealing with an error message like this:

error: expected expression, found `/*«*/`

than the previous, which was presumably:

error: expected expression, found ``

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 4, 2022

📌 Commit 5022d76 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 4, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request May 5, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#95359 (Update `int_roundings` methods from feedback)
 - rust-lang#95843 (Improve Rc::new_cyclic and Arc::new_cyclic documentation)
 - rust-lang#96507 (Suggest calling `Self::associated_function()`)
 - rust-lang#96635 (Use "strict" mode in JS scripts)
 - rust-lang#96673 (Report that opaque types are not allowed in impls even in the presence of other errors)
 - rust-lang#96682 (Show invisible delimeters (within comments) when pretty printing.)
 - rust-lang#96714 (interpret/validity: debug-check ScalarPair layout information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7a915dd into rust-lang:master May 5, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 5, 2022
@nnethercote nnethercote deleted the show-invisible-delims branch May 5, 2022 20:46
@nnethercote nnethercote mentioned this pull request May 6, 2022
nnethercote added a commit to nnethercote/rust that referenced this pull request Jun 2, 2022
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.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request 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 pull request 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 added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#97420 (Be a little nicer with casts when formatting `fn` pointers)
 - rust-lang#97450 ([RFC 2011] Basic compiler infrastructure)
 - rust-lang#97599 (Fix JSON reexport ICE)
 - rust-lang#97617 (Rustdoc anonymous reexports)
 - rust-lang#97636 (Revert rust-lang#96682.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
ehuss pushed a commit to ehuss/rust that referenced this pull request 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``
@ehuss ehuss mentioned this pull request Jun 24, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2022
[beta] Beta backports

* Remove the unused-#[doc(hidden)] logic from the unused_attributes lint rust-lang#98336
* debuginfo: Fix NatVis for Rc and Arc with unsized pointees. rust-lang#98137
* Revert "remove num_cpus dependency" in rustc and update cargo rust-lang#97911
* Update LLVM submodule rust-lang#97690
* Revert rust-lang#96682. rust-lang#97636
* don't do Sized and other return type checks on RPIT's real type rust-lang#97431
* Temporarily disable submodule archive downloads. rust-lang#98423
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants