From 1d8f29136b9969e361b4186d6a597b12140cae78 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Mon, 25 Aug 2025 11:00:49 +0200 Subject: [PATCH 1/2] Rust: Include `getAttributeMacroExpansion` in `isInMacroExpansion` --- rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll | 2 ++ 1 file changed, 2 insertions(+) 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()) } From 9b4d37df242567c2b387b93eadcd77ece4f31374 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Mon, 25 Aug 2025 20:49:10 +0200 Subject: [PATCH 2/2] Add change note --- rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md 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