-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Correctly check if a macro call is actually a macro call in rustdoc highlighter #152394
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
+81
−5
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
This comment has been minimized.
This comment has been minimized.
747883d to
59e17a5
Compare
This comment has been minimized.
This comment has been minimized.
59e17a5 to
75f04aa
Compare
Member
Author
|
Finally made unit tests happy as well. |
Contributor
|
fn main() {
let macro_rules = 3;
dbg!(macro_rules != 3);
}I don't think this is handled correctly. |
Member
Author
|
TIL, so yeah, fix is invalid. |
75f04aa to
31c4ad3
Compare
Member
Author
|
Hopefully it's good now. |
Contributor
|
I think everything is handled correctly now, but I've found an even more absurd edge case, unsure if it's worthy of an additional test case. macro_rules! r#macro_rules {
() => {
fn main() {
println!("why can you do this.");
}
}
}
r#macro_rules!(); |
Member
Author
|
I added a test for this case too. :) |
Contributor
|
Thanks! @bors r+ rollup |
Contributor
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Feb 12, 2026
…narycat Correctly check if a macro call is actually a macro call in rustdoc highlighter Fixes rust-lang#151904. Issues was that if there was a `!` following an ident, we would always assume it's a macro call... except it's very lacking. I'm actually surprised it went for so long unnoticed. To fix it, I added a check for the next (non-blank) token after the `!`, if it's a `{` or a `[` or a `(`, then only do we consider it to be a macro call. r? @lolbinarycat
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 12, 2026
Rollup of 17 pull requests Successful merges: - #142415 (Add note when inherent impl for a alias type defined outside of the crate) - #142680 (Fix passing/returning structs with the 64-bit SPARC ABI) - #150768 (Don't compute FnAbi for LLVM intrinsics in backends) - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes) - #151814 (layout: handle rigid aliases without params) - #151863 (Borrowck: simplify diagnostics for placeholders) - #152159 (Add note for `?Sized` params in int-ptr casts diag) - #152434 (Clarify names of `QueryVTable` functions for "executing" a query) - #152478 (Remove tm_factory field from CodegenContext) - #152498 (Partially revert "resolve: Update `NameBindingData::vis` in place") - #152316 (fix: add continue) - #152394 (Correctly check if a macro call is actually a macro call in rustdoc highlighter) - #152425 (Port #![test_runner] to the attribute parser) - #152481 (Use cg_ssa's produce_final_output_artifacts in cg_clif) - #152485 (fix issue#152482) - #152495 (Clean up some subdiagnostics) - #152502 (Implement `BinaryHeap::from_raw_vec`)
rust-timer
added a commit
that referenced
this pull request
Feb 12, 2026
Rollup merge of #152394 - GuillaumeGomez:macro-call, r=lolbinarycat Correctly check if a macro call is actually a macro call in rustdoc highlighter Fixes #151904. Issues was that if there was a `!` following an ident, we would always assume it's a macro call... except it's very lacking. I'm actually surprised it went for so long unnoticed. To fix it, I added a check for the next (non-blank) token after the `!`, if it's a `{` or a `[` or a `(`, then only do we consider it to be a macro call. r? @lolbinarycat
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-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
T-rustdoc-frontend
Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
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.
Fixes #151904.
Issues was that if there was a
!following an ident, we would always assume it's a macro call... except it's very lacking. I'm actually surprised it went for so long unnoticed. To fix it, I added a check for the next (non-blank) token after the!, if it's a{or a[or a(, then only do we consider it to be a macro call.r? @lolbinarycat