Skip to content

mbe: Rework diagnostics for metavariable expressions #142950

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Jun 24, 2025

Make the diagnostics for metavariable expressions more user-friendly. This mostly addresses syntactic errors; I will be following up with improvements to concat(..).

r? @petrochenkov

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 24, 2025

There are changes to the tidy tool.

cc @jieyouxu

@tgross35 tgross35 added the F-macro_metavar_expr `#![feature(macro_metavar_expr)]` label Jun 24, 2025
@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 Jun 24, 2025
@tgross35 tgross35 changed the title mbe: Rework diagnostics for metavariable expressions. mbe: Rework diagnostics for metavariable expressions Jun 30, 2025
@tgross35
Copy link
Contributor Author

I split the nonfunctional changes here to a new PR, #143245. I think this should make it a bit more straightforward to do the other changes here.

@petrochenkov
Copy link
Contributor

Blocked on #143245.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 30, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 1, 2025
…ation, r=petrochenkov

mbe: Add tests and restructure metavariable expressions

Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details.

This performs the nonfunctional perparation for further changes such as rust-lang#142950 and rust-lang#142975 .
@tgross35
Copy link
Contributor Author

tgross35 commented Jul 1, 2025

@rustbot author
after that merges I’m going to do some cleanup of this and the remaining draft PR

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

rust-timer added a commit that referenced this pull request Jul 1, 2025
Rollup merge of #143245 - tgross35:metavariable-expr-organization, r=petrochenkov

mbe: Add tests and restructure metavariable expressions

Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details.

This performs the nonfunctional perparation for further changes such as #142950 and #142975 .
@bors

This comment was marked as resolved.

@tgross35 tgross35 force-pushed the metavariable-expr-rework branch 2 times, most recently from 51693ef to 1146773 Compare July 4, 2025 06:37
@rust-log-analyzer

This comment has been minimized.

@tgross35 tgross35 force-pushed the metavariable-expr-rework branch 3 times, most recently from 13a7e49 to 7e5760b Compare July 4, 2025 08:55
@tgross35 tgross35 force-pushed the metavariable-expr-rework branch from 7e5760b to 5366b37 Compare July 4, 2025 08:58
@tgross35
Copy link
Contributor Author

tgross35 commented Jul 4, 2025

I rebased on top of #143245 and dropped the more confusing identifier changes, which makes more sense to bring back as part of #142975.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 4, 2025
@tgross35 tgross35 force-pushed the metavariable-expr-rework branch from 5366b37 to b276ff8 Compare July 4, 2025 09:28
@petrochenkov
Copy link
Contributor

r=me with the comments addressed.
@rustbot author

@rustbot rustbot 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 Jul 9, 2025
@tgross35 tgross35 force-pushed the metavariable-expr-rework branch from b276ff8 to dff37db Compare July 10, 2025 01:10
tgross35 added 2 commits July 9, 2025 21:11
Give a more user-friendly diagnostic about the following:

* Trailing tokens within braces, e.g. `${foo() extra}`
* Missing parentheses, e.g. `${foo}`
* Incorrect number of arguments, with a hint about correct usage.
Change to a structural diagnostic, update the valid list, and move the
valid list to a note.
@tgross35 tgross35 force-pushed the metavariable-expr-rework branch from dff37db to 87e9819 Compare July 10, 2025 01:15
@tgross35
Copy link
Contributor Author

Applied the suggestions then rebased.

@bors r=petrochenkov rollup

@bors
Copy link
Collaborator

bors commented Jul 10, 2025

📌 Commit 87e9819 has been approved by petrochenkov

It is now in the queue for this repository.

@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 Jul 10, 2025
tgross35 added a commit to tgross35/rust that referenced this pull request Jul 10, 2025
… r=petrochenkov

mbe: Rework diagnostics for metavariable expressions

Make the diagnostics for metavariable expressions more user-friendly. This mostly addresses syntactic errors; I will be following up with improvements to `concat(..)`.
bors added a commit that referenced this pull request Jul 10, 2025
Rollup of 9 pull requests

Successful merges:

 - #141996 (Fix `proc_macro::Ident`'s handling of `$crate`)
 - #142911 (Remove support for dynamic allocas)
 - #142950 (mbe: Rework diagnostics for metavariable expressions)
 - #143270 (tests/codegen/enum/enum-match.rs: accept negative range attribute)
 - #143298 (`tests/ui`: A New Order [23/N])
 - #143398 (tidy: add support for `--extra-checks=auto:` feature)
 - #143632 (fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuildMaxNum FFI declarations)
 - #143644 (Add triagebot stdarch mention ping)
 - #143651 (Win: Use exceptions with empty data for SEH panic exception copies instead of a new panic)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 10, 2025
Rollup of 9 pull requests

Successful merges:

 - #141996 (Fix `proc_macro::Ident`'s handling of `$crate`)
 - #142950 (mbe: Rework diagnostics for metavariable expressions)
 - #143011 (Make lint `ambiguous_glob_imports` deny-by-default and report-in-deps)
 - #143265 (Mention as_chunks in the docs for chunks)
 - #143270 (tests/codegen/enum/enum-match.rs: accept negative range attribute)
 - #143298 (`tests/ui`: A New Order [23/N])
 - #143396 (Move NaN tests to floats/mod.rs)
 - #143398 (tidy: add support for `--extra-checks=auto:` feature)
 - #143644 (Add triagebot stdarch mention ping)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 643efda into rust-lang:master Jul 10, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 10, 2025
rust-timer added a commit that referenced this pull request Jul 10, 2025
Rollup merge of #142950 - tgross35:metavariable-expr-rework, r=petrochenkov

mbe: Rework diagnostics for metavariable expressions

Make the diagnostics for metavariable expressions more user-friendly. This mostly addresses syntactic errors; I will be following up with improvements to `concat(..)`.
@tgross35 tgross35 deleted the metavariable-expr-rework branch July 10, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool F-macro_metavar_expr `#![feature(macro_metavar_expr)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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