Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ module Impl {
*/
pragma[nomagic]
predicate isFromMacroExpansion() {
exists(MacroCall mc |
MacroCallImpl::isInMacroExpansion(mc, this) and
not this = mc.getATokenTreeNode()
exists(AstNode root |
MacroCallImpl::isInMacroExpansion(root, this) and
not this = root.(MacroCall).getATokenTreeNode()
)
}

Expand Down
8 changes: 5 additions & 3 deletions rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ module Impl {
private import rust

pragma[nomagic]
predicate isInMacroExpansion(MacroCall mc, AstNode n) {
n = mc.getMacroCallExpansion()
predicate isInMacroExpansion(AstNode root, AstNode n) {
n = root.(MacroCall).getMacroCallExpansion()
or
isInMacroExpansion(mc, n.getParentNode())
n = root.(Adt).getDeriveMacroExpansion(_)
or
isInMacroExpansion(root, n.getParentNode())
}
Comment on lines +20 to 23
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Instead of using the wildcard _ for the derive expansion, bind it to a named variable (e.g. getDeriveMacroExpansion(deriveExp)) to improve readability.

Suggested change
n = root.(Adt).getDeriveMacroExpansion(_)
or
isInMacroExpansion(root, n.getParentNode())
}
n = root.(Adt).getDeriveMacroExpansion(deriveExp)
or
isInMacroExpansion(root, n.getParentNode())
}
AstNode deriveExp;

Copilot uses AI. Check for mistakes.

// the following QLdoc is generated: if you need to edit it, do it in the schema file
Expand Down
Loading