11private import rust
22private import codeql.rust.controlflow.ControlFlowGraph
3+ private import codeql.rust.internal.PathResolution as PathResolution
34private import codeql.rust.elements.internal.generated.ParentChild as ParentChild
5+ private import codeql.rust.elements.internal.AstNodeImpl:: Impl as AstNodeImpl
46private import codeql.rust.elements.internal.PathImpl:: Impl as PathImpl
57private import codeql.rust.elements.internal.PathExprBaseImpl:: Impl as PathExprBaseImpl
68private import codeql.rust.elements.internal.FormatTemplateVariableAccessImpl:: Impl as FormatTemplateVariableAccessImpl
@@ -98,7 +100,7 @@ module Impl {
98100 * pattern.
99101 */
100102 cached
101- private predicate variableDecl ( AstNode definingNode , Name name , string text ) {
103+ predicate variableDecl ( AstNode definingNode , Name name , string text ) {
102104 Cached:: ref ( ) and
103105 exists ( SelfParam sp |
104106 name = sp .getName ( ) and
@@ -117,11 +119,7 @@ module Impl {
117119 not exists ( getOutermostEnclosingOrPat ( pat ) ) and definingNode = name
118120 ) and
119121 text = name .getText ( ) and
120- // exclude for now anything starting with an uppercase character, which may be a reference to
121- // an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
122- // which we don't appear to recognize yet anyway. This also assumes programmers follow the
123- // naming guidelines, which they generally do, but they're not enforced.
124- not text .charAt ( 0 ) .isUppercase ( ) and
122+ not PathResolution:: identPatIsResolvable ( pat ) and
125123 // exclude parameters from functions without a body as these are trait method declarations
126124 // without implementations
127125 not exists ( Function f | not f .hasBody ( ) and f .getAParam ( ) .getPat ( ) = pat ) and
0 commit comments