Skip to content

Commit faef735

Browse files
committed
Rust: Move equality into disjunction
1 parent dcfe65b commit faef735

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ module Impl {
7575
* pattern.
7676
*/
7777
private predicate variableDecl(AstNode definingNode, Name name, string text) {
78-
text = name.getText() and
7978
(
8079
exists(SelfParam sp |
8180
name = sp.getName() and
8281
definingNode = name and
82+
text = name.getText() and
8383
// exclude self parameters from functions without a body as these are
8484
// trait method declarations without implementations
8585
not exists(Function f | not f.hasBody() and f.getParamList().getSelfParam() = sp)
@@ -92,6 +92,7 @@ module Impl {
9292
or
9393
not exists(getOutermostEnclosingOrPat(pat)) and definingNode = name
9494
) and
95+
text = name.getText() and
9596
// exclude for now anything starting with an uppercase character, which may be a reference to
9697
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
9798
// which we don't appear to recognize yet anyway. This also assumes programmers follow the

0 commit comments

Comments
 (0)