Merge pull request #19850 from hvitved/rust/in-derive-macro

Rust: Take derive macros into account in `is{In,From}MacroExpansion`
This commit is contained in:
Tom Hvitved
2025-06-23 17:16:02 +02:00
committed by GitHub
3 changed files with 8 additions and 1099 deletions

View File

@@ -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()
)
}

View File

@@ -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())
}
// the following QLdoc is generated: if you need to edit it, do it in the schema file