Skip to content

Commit dfeb35f

Browse files
committed
Rust: Move the restriction to variableDecl.
1 parent a66f31d commit dfeb35f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,20 @@ module Impl {
7777
not exists(getOutermostEnclosingOrPat(p)) and
7878
definingNode = p.getName()
7979
) and
80-
name = p.getName().getText()
80+
name = p.getName().getText() and
81+
// exclude for now anything starting with an uppercase character, which may be a reference to
82+
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
83+
// which we don't appear to recognize yet anyway. This also assumes programmers follow the
84+
// naming guidelines, which they generally do, but they're not enforced.
85+
not name.charAt(0).isUppercase()
8186
}
8287

8388
/** A variable. */
8489
class Variable extends MkVariable {
8590
private AstNode definingNode;
8691
private string name;
8792

88-
Variable() {
89-
this = MkVariable(definingNode, name) and
90-
// exclude for now anything starting with an uppercase character, which may be an enum constant (e.g. `None`). This excludes
91-
// static and constant variables (UPPERCASE), which we don't appear to recognize yet anyway. This also assumes programmers
92-
// follow the naming guidelines, which they generally do, but they're not enforced.
93-
not name.charAt(0).isUppercase()
94-
}
93+
Variable() { this = MkVariable(definingNode, name) }
9594

9695
/** Gets the name of this variable. */
9796
string getName() { result = name }

0 commit comments

Comments
 (0)