Skip to content

Commit 8a35e15

Browse files
committed
Rust: Move the function pointer parameter exclusion into VariableImpl.qll.
1 parent 1a5d2e1 commit 8a35e15

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ module Impl {
8787
not name.charAt(0).isUppercase() and
8888
// exclude parameters from functions without a body as these are trait method declarations
8989
// without implementations
90-
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = p)
90+
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = p) and
91+
// exclude parameters from function pointers as well, which also lack a body
92+
not exists(FnPtrType fp | fp.getParamList().getParam(_).getPat() = p)
9193
}
9294

9395
/** A variable. */

rust/ql/src/queries/unusedentities/UnusedVariable.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,4 @@ predicate isUnused(Variable v) {
2323
predicate isAllowableUnused(Variable v) {
2424
// in a macro expansion
2525
v.getPat().isInMacroExpansion()
26-
or
27-
// function pointer parameters
28-
exists(FnPtrType fp | fp.getParamList().getParam(_).getPat() = v.getPat())
2926
}

0 commit comments

Comments
 (0)