Rust: Move the function pointer parameter exclusion into VariableImpl.qll.

This commit is contained in:
Geoffrey White
2024-11-06 10:51:41 +00:00
parent 1a5d2e1f5d
commit 8a35e151d1
2 changed files with 3 additions and 4 deletions

View File

@@ -87,7 +87,9 @@ module Impl {
not name.charAt(0).isUppercase() and
// exclude parameters from functions without a body as these are trait method declarations
// without implementations
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = p)
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = p) and
// exclude parameters from function pointers as well, which also lack a body
not exists(FnPtrType fp | fp.getParamList().getParam(_).getPat() = p)
}
/** A variable. */

View File

@@ -23,7 +23,4 @@ predicate isUnused(Variable v) {
predicate isAllowableUnused(Variable v) {
// in a macro expansion
v.getPat().isInMacroExpansion()
or
// function pointer parameters
exists(FnPtrType fp | fp.getParamList().getParam(_).getPat() = v.getPat())
}