diff --git a/rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md b/rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md new file mode 100644 index 000000000000..1778c42d9b88 --- /dev/null +++ b/rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* Attribute macros are now taken into account when identifying macro-expanded code. This affects the queries `rust/unused-variable` and `rust/unused-value`, which exclude results in macro-expanded code. \ No newline at end of file diff --git a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll index 27f70c77074c..0ed4d3073f05 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll @@ -19,6 +19,8 @@ module Impl { or n = root.(Adt).getDeriveMacroExpansion(_) or + n = root.(Item).getAttributeMacroExpansion() + or isInMacroExpansion(root, n.getParentNode()) }