@@ -76,9 +76,27 @@ query predicate multiplePositions(Element parent, int pos1, int pos2, string acc
7676private import codeql.rust.elements.internal.PathResolution
7777
7878/** Holds if `p` may resolve to multiple items including `i`. */
79- query predicate multiplePathResolutions ( Path p , ItemNode i ) {
80- i = resolvePath ( p ) and
81- strictcount ( resolvePath ( p ) ) > 1
79+ query predicate multiplePathResolutions ( Path p , Namespace ns , ItemNode i ) {
80+ i = resolvePath ( p , ns ) and
81+ strictcount ( resolvePath ( p , ns ) ) > 1
82+ }
83+
84+ /** Holds if `call` has multiple static call targets including `target`. */
85+ query predicate multipleStaticCallTargets ( CallExprBase call , Callable target ) {
86+ target = call .getStaticTarget ( ) and
87+ strictcount ( call .getStaticTarget ( ) ) > 1
88+ }
89+
90+ /** Holds if `fe` resolves to multiple record fields including `field`. */
91+ query predicate multipleRecordFields ( FieldExpr fe , RecordField field ) {
92+ field = fe .getRecordField ( ) and
93+ strictcount ( fe .getRecordField ( ) ) > 1
94+ }
95+
96+ /** Holds if `fe` resolves to multiple tuple fields including `field`. */
97+ query predicate multipleTupleFields ( FieldExpr fe , TupleField field ) {
98+ field = fe .getTupleField ( ) and
99+ strictcount ( fe .getTupleField ( ) ) > 1
82100}
83101
84102/**
@@ -108,5 +126,14 @@ int getAstInconsistencyCounts(string type) {
108126 result = count ( Element e | multiplePositions ( _, _, _, _, e ) | e )
109127 or
110128 type = "Multiple path resolutions" and
111- result = count ( Path p | multiplePathResolutions ( p , _) | p )
129+ result = count ( Path p | multiplePathResolutions ( p , _, _) | p )
130+ or
131+ type = "Multiple static call targets" and
132+ result = count ( CallExprBase call | multipleStaticCallTargets ( call , _) | call )
133+ or
134+ type = "Multiple record fields" and
135+ result = count ( FieldExpr fe | multipleRecordFields ( fe , _) | fe )
136+ or
137+ type = "Multiple tuple fields" and
138+ result = count ( FieldExpr fe | multipleTupleFields ( fe , _) | fe )
112139}
0 commit comments