Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: Exclude results inside macro expansions from unused entity queries #17865

Merged
merged 5 commits into from
Nov 3, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 29, 2024

No description provided.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@hvitved hvitved force-pushed the rust/unused-macro-expansion branch from 072b836 to 2a68d6d Compare October 29, 2024 13:49
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Looks great!

One question, for my education.

We need to wait for the underlying PR to be merged, and probably do a DCA run.

* Gets the nearest enclosing parent of this node, which is also an `AstNode`,
* if any.
*/
AstNode getParentNode() { result = getParentOfAstStep*(getImmediateParent(this)) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer getParent . I think all immediate parents are actually AstNodes, and if not, we should probably change the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't be named getParent because it will then conflict with the auto-generated Comment.getParent predicate :-(

@@ -434,7 +438,7 @@
fn increment(
&mut self,
times: i32,
unused: i32, // $ Alert[rust/unused-variable]
unused: &mut i32, // $ Alert[rust/unused-variable]

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'unused' is not used.
// --- macros ---

fn macros() {
let x;

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'x' is not used.
@hvitved hvitved marked this pull request as ready for review October 31, 2024 10:55
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

LGTM.

@hvitved hvitved merged commit 662a824 into github:main Nov 3, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants