-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: expand attribute macros on AssocItem
#19786
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR generalizes attribute-macro expansions to both top-level Item
s and associated items (AssocItem
) by introducing a new ExpandableItem
type and wiring it through the schema, extractor, and QL libraries.
- Introduce
ExpandableItem
in the AST schema and annotate bothItem
andAssocItem
as bases - Update the DB scheme to define
@expandable_item
and replace the olditem_attribute_macro_expansions
relation - Enhance the Rust extractor (
base.rs
) to pre- and post-emit attribute expansions forAssocItem
as well asItem
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
rust/schema/prelude.py | Adds new ExpandableItem ASTNode |
rust/schema/annotations.py | Annotates AssocItem & Item to inherit from ExpandableItem |
rust/ql/lib/rust.dbscheme | Defines @expandable_item , removes old relation, re-adds @assoc_item later |
rust/ql/lib/codeql/rust/elements/ExpandableItem*.qll | Generates public and internal QLL wrappers for ExpandableItem |
rust/ql/lib/codeql/rust/elements/Item.qll & AssocItem.qll | Switch imports to use ExpandableItem |
rust/extractor/src/translate/base.rs | Extends translator macros and methods to handle AssocItem expansions |
rust/ql/integration-tests/macro-expansion | Updates expected outputs and test fixtures for assoc-item expansions |
rust/ql/lib/upgrades/.../upgrade.properties | Adds upgrade to rename the expansion relation |
rust/ql/lib/downgrades/.../downgrade.ql | Provides downgrade path |
Comments suppressed due to low confidence (1)
rust/extractor/src/translate/base.rs:708
- The return type was changed to
Option<Label<generated::MacroCall>>
, but callers in the pre‐emit and post‐emit macros expect labels forItem
orAssocItem
. This mismatch may lead to compilation errors—consider restoring the originalLabel<generated::Item>
return type or updating the macros to handleMacroCall
labels explicitly.
pub(crate) fn prepare_item_expansion(
It turned out that #19334 was not covering the case of items in
Impl
orTrait
blocks, because internally those areAssocItem
instances rather thanItem
ones. This covers that case.