Skip to content

Add hightlight to acceptable characters in macro rules - #164060

Open
mtan37 wants to merge 1 commit into
rust-lang:mainfrom
mtan37:issue-156458
Open

mtan37 wants to merge 1 commit into
rust-lang:mainfrom
mtan37:issue-156458

Conversation

@mtan37

@mtan37 mtan37 commented Oct 9, 2026 •

Copy link
Copy Markdown

fixes #156458
cc @estebank

LLM disclosure: LL was used to generate a malformed testing macro case to exercise the logic modified. LLM was also used to review the code, and pointed out it might be better to also highlight the symbol in the single symbol match case, so I modified that logic as well. However, I was not able to craft a testing macro that trigger the logic at line 1649, so I just tested the logic by temporarily moving the logic to the match all block(line 1657) to make sure the generated output looks correct.

Before:
Screenshot From 2026-10-09 12-31-50

After:
Screenshot From 2026-10-09 16-38-03

Add logic to highlight accepted characters in macro rules

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 9, 2026
@rustbot

rustbot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @fee1-dead (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 17 candidates

@rust-log-analyzer

This comment has been minimized.

@estebank

estebank commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

You'll want to write a test like https://github.com/rust-lang/rust/blob/56d6b4e427c271e8f069500f6fac4e209e946144/tests/ui/error-emitter/highlighting.rs so that this is actually tested.

Searching for IsInFollow::No, I don't think there's any case of a single token being allowed (which would trigger that condition for testing). Still, leave that branch in for future proofing.

Looking at the screenshot, the highlighting includes the backticks, which ideally we'd not include in the highlight, but there are also words (like "an ident" or "a type"), so I guess its ok to have the logic be what it is now.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_expand/src/mbe/macro_rules.rs Outdated
@fee1-dead

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned davidtwco and unassigned fee1-dead Oct 16, 2026
@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5754b4a has been approved by estebank

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 16, 2026
Add hightlight to acceptable characters in macro rules

Add logic to highlight accepted characters in macro rules
rust-bors Bot pushed a commit that referenced this pull request Oct 16, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #163731 (Add bootstrap step to build the TPDE plugin)
 - #164060 (Add hightlight to acceptable characters in macro rules)
 - #164424 (diagnostic: skip wrong loops when explaining borrow errors)
 - #162444 (Make `std::fs::{File, ReadDir, DirEntry}` always `needs_drop` even when unsupported.)
@JonathanBrouwer

Copy link
Copy Markdown
Member

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #164445 (comment)

@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 16, 2026
@rust-bors

rust-bors Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#164445), which was unapproved.

View changes since this unapproval

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

rustc lexer/macro_rules diagnostics feature request: Color highlight acceptable characters

7 participants