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
5- private import codeql.rust.elements.internal.PathExprBaseImpl:: Impl as PathExprBaseImpl
67private import codeql.rust.elements.internal.FormatTemplateVariableAccessImpl:: Impl as FormatTemplateVariableAccessImpl
78private import codeql.util.DenseRank
89
@@ -98,7 +99,7 @@ module Impl {
9899 * pattern.
99100 */
100101 cached
101- private predicate variableDecl ( AstNode definingNode , Name name , string text ) {
102+ predicate variableDecl ( AstNode definingNode , Name name , string text ) {
102103 Cached:: ref ( ) and
103104 exists ( SelfParam sp |
104105 name = sp .getName ( ) and
@@ -117,11 +118,7 @@ module Impl {
117118 not exists ( getOutermostEnclosingOrPat ( pat ) ) and definingNode = name
118119 ) and
119120 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
121+ not PathResolution:: identPatIsResolvable ( pat ) and
125122 // exclude parameters from functions without a body as these are trait method declarations
126123 // without implementations
127124 not exists ( Function f | not f .hasBody ( ) and f .getAParam ( ) .getPat ( ) = pat ) and
@@ -666,7 +663,7 @@ module Impl {
666663 }
667664
668665 /** A variable access. */
669- class VariableAccess extends PathExprBaseImpl :: PathExprBase {
666+ class VariableAccess extends PathExprBase {
670667 private string name ;
671668 private Variable v ;
672669
@@ -677,10 +674,6 @@ module Impl {
677674
678675 /** Holds if this access is a capture. */
679676 predicate isCapture ( ) { this .getEnclosingCfgScope ( ) != v .getEnclosingCfgScope ( ) }
680-
681- override string toStringImpl ( ) { result = name }
682-
683- override string getAPrimaryQlClass ( ) { result = "VariableAccess" }
684677 }
685678
686679 /** Holds if `e` occurs in the LHS of an assignment or compound assignment. */
@@ -722,7 +715,7 @@ module Impl {
722715 }
723716
724717 /** A nested function access. */
725- class NestedFunctionAccess extends PathExprBaseImpl :: PathExprBase {
718+ class NestedFunctionAccess extends PathExprBase {
726719 private Function f ;
727720
728721 NestedFunctionAccess ( ) { nestedFunctionAccess ( _, f , this ) }
0 commit comments