Repository navigation
Conversation
Use a node's own text range outside macro expansions, skip the attribute macro check for items without attributes, and reuse the pre-emit decision in `item_post_emit`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b98227f5d3a24d73abe15df037acd68e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b98227f5d3a24d73abe15df037acd68e
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The source-location fast path changes extractor-wide provenance invariants across nested macro, include, attribute, and derive expansions, requiring human review of their interactions.
No open issues 🎉
What changed in this PR
Reduces rust-analyzer semantic queries in the Rust extractor while preserving macro-expansion location handling.
Changes:
- Uses syntax ranges outside expansions and avoids redundant attribute-macro checks.
- Adds regression coverage for inner-attribute macros.
- Documents the expansion-emission invariant.
| File | Description |
|---|---|
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/test.ql |
Queries attribute-macro expansion results. |
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/test.expected |
Records expected expansion results and locations. |
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/proc_macro.rs |
Defines the test attribute macro. |
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/options.yml |
Disables Cargo checking for the nightly-only syntax. |
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/inner.rs |
Exercises an inner-attribute macro. |
rust/ql/test/extractor-tests/macro-expansion-inner-attribute/Cargo.lock |
Locks test dependencies. |
rust/extractor/src/translate/base.rs |
Tracks expansion context and reuses attribute-macro decisions. |
.github/instructions/rust-extractor.instructions.md |
Documents safe emission of expanded syntax. |
Review effort: Balanced (adaptive)
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
fe2a07d1ae04455df440ff9b6bfa4d05d4b62d19↑ Mutation checks: dropping
in_expansionbreaks macro-expansion/macro-in-library; an outer-attributes-only guard breaks the new inner-attribute test.↑ 8/8 fact-parity queries identical on a ripgrep DB.
↓ PR CI not yet observed.
↓ Future expansion call sites rely on documentation, not a lint.
First layer of an extractor performance stack. Cuts rust-analyzer semantic queries in
translate/base.rs:Semantics::original_rangeis only used insidein_expansion(include, nested, attribute and built-in derive mapping unchanged).item_post_emitreuses the decision made initem_pre_emitinstead of querying again.Also adds a Copilot instruction for the
in_expansioninvariant and a test for an attribute macro used as an inner attribute.On a noisy local ripgrep DB create (8 threads, 2 runs each) this layer took ~98s vs ~101–109s on
main.