-
Notifications
You must be signed in to change notification settings - Fork 13.5k
mbe: Gracefully handle macro rules that end after =>
#143408
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
+87
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a test for various cases of invalid macro definitions. Closes: rust-lang#143351
rustbot has assigned @petrochenkov. Use |
bors
added a commit
that referenced
this pull request
Jul 4, 2025
mbe: Defer checks for `compile_error!` until reporting an unused macro rule The current MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking. Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused. In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes. This builds atop a couple of minor MBE refactors. I would suggest reviewing commit-by-commit. This PR builds atop the fix for #143408 to avoid conflicts.
bors
added a commit
that referenced
this pull request
Jul 4, 2025
mbe: Defer checks for `compile_error!` until reporting an unused macro rule The current MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking. Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused. In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes. This builds atop a couple of minor MBE refactors. I would suggest reviewing commit-by-commit. This PR builds atop the fix for #143408 to avoid conflicts.
compiler-errors
approved these changes
Jul 4, 2025
r? compiler-errors @bors r+ rollup |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 4, 2025
…piler-errors mbe: Gracefully handle macro rules that end after `=>` Add a test for various cases of invalid macro definitions. Closes: rust-lang#143351
bors
added a commit
that referenced
this pull request
Jul 4, 2025
Rollup of 9 pull requests Successful merges: - #141532 (std: sys: net: uefi: tcp4: Implement write) - #143085 (Port `#[non_exhaustive]` to the new attribute parsing infrastructure) - #143298 (`tests/ui`: A New Order [23/N]) - #143372 (Remove names_imported_by_glob_use query.) - #143386 (Assign dependency bump PRs to me) - #143406 (Remove some unnecessary `unsafe` in VecCache) - #143408 (mbe: Gracefully handle macro rules that end after `=>`) - #143414 (remove special-casing of boxes from match exhaustiveness/usefulness analysis) - #143444 (clean up GVN TypeId test) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Jul 4, 2025
Rollup of 8 pull requests Successful merges: - #141532 (std: sys: net: uefi: tcp4: Implement write) - #143085 (Port `#[non_exhaustive]` to the new attribute parsing infrastructure) - #143372 (Remove names_imported_by_glob_use query.) - #143386 (Assign dependency bump PRs to me) - #143406 (Remove some unnecessary `unsafe` in VecCache) - #143408 (mbe: Gracefully handle macro rules that end after `=>`) - #143414 (remove special-casing of boxes from match exhaustiveness/usefulness analysis) - #143444 (clean up GVN TypeId test) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a test for various cases of invalid macro definitions.
Closes: #143351