Skip to content

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Aug 25, 2025

When investigating this false positive report, I realized that the underlying cause was that attribute macros were not taken into account when filtering away results inside expansions.

DCA confirms that the FPs have been eliminated.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Aug 25, 2025
@hvitved hvitved marked this pull request as ready for review August 25, 2025 18:52
@hvitved hvitved requested a review from a team as a code owner August 25, 2025 18:52
@Copilot Copilot AI review requested due to automatic review settings August 25, 2025 18:52
Copy link
Contributor

@Copilot Copilot AI left a 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 fixes false positives in Rust queries by ensuring that attribute macro expansions are properly identified as macro-expanded code. The change updates the isInMacroExpansion predicate to include attribute macros, which will prevent queries like rust/unused-variable and rust/unused-value from reporting issues within attribute macro expansions.

  • Added attribute macro expansion detection to the isInMacroExpansion predicate
  • Added change notes documenting the improvement for minorAnalysis category

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll Enhanced macro expansion detection to include attribute macros
rust/ql/lib/change-notes/2025-08-25-in-macro-expansion.md Documents the fix for attribute macro handling in analysis

@hvitved hvitved merged commit 80031e5 into github:main Aug 26, 2025
20 checks passed
@hvitved hvitved deleted the rust/attribute-in-macro-expansion branch August 26, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants