Rust: fix QL compilation errors after renames

This commit is contained in:
Paolo Tranquilli
2025-03-27 16:20:08 +01:00
parent 394f3eb1be
commit ece2f03f0f
18 changed files with 32 additions and 32 deletions

View File

@@ -329,7 +329,7 @@ module ExprTrees {
} }
class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr { class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr {
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() } override AstNode getChildNode(int i) { i = 0 and result = super.getContainer() }
} }
class IfExprTree extends PostOrderTree instanceof IfExpr { class IfExprTree extends PostOrderTree instanceof IfExpr {

View File

@@ -150,7 +150,7 @@ final class TuplePositionContent extends FieldContent, TTuplePositionContent {
override FieldExprCfgNode getAnAccess() { override FieldExprCfgNode getAnAccess() {
// TODO: limit to tuple types // TODO: limit to tuple types
result.getNameRef().getText().toInt() = pos result.getIdentifier().getText().toInt() = pos
} }
override string toString() { result = "tuple." + pos.toString() } override string toString() { result = "tuple." + pos.toString() }
@@ -262,7 +262,7 @@ newtype TContent =
TTuplePositionContent(int pos) { TTuplePositionContent(int pos) {
pos in [0 .. max([ pos in [0 .. max([
any(TuplePat pat).getNumberOfFields(), any(TuplePat pat).getNumberOfFields(),
any(FieldExpr access).getNameRef().getText().toInt() any(FieldExpr access).getIdentifier().getText().toInt()
] ]
)] )]
} or } or

View File

@@ -688,7 +688,7 @@ module RustDataFlow implements InputSig<Location> {
node1.asPat().(RefPatCfgNode).getPat() = node2.asPat() node1.asPat().(RefPatCfgNode).getPat() = node2.asPat()
or or
exists(FieldExprCfgNode access | exists(FieldExprCfgNode access |
node1.asExpr() = access.getExpr() and node1.asExpr() = access.getContainer() and
node2.asExpr() = access and node2.asExpr() = access and
access = c.(FieldContent).getAnAccess() access = c.(FieldContent).getAnAccess()
) )
@@ -771,7 +771,7 @@ module RustDataFlow implements InputSig<Location> {
exists(AssignmentExprCfgNode assignment, FieldExprCfgNode access | exists(AssignmentExprCfgNode assignment, FieldExprCfgNode access |
assignment.getLhs() = access and assignment.getLhs() = access and
node1.asExpr() = assignment.getRhs() and node1.asExpr() = assignment.getRhs() and
node2.asExpr() = access.getExpr() and node2.asExpr() = access.getContainer() and
access = c.getAnAccess() access = c.getAnAccess()
) )
} }

View File

@@ -47,7 +47,7 @@ module Input implements InputSig<Location, RustDataFlow> {
private class MethodCallExprNameRef extends SourceBase, SinkBase { private class MethodCallExprNameRef extends SourceBase, SinkBase {
private MethodCallExpr call; private MethodCallExpr call;
MethodCallExprNameRef() { this = call.getNameRef() } MethodCallExprNameRef() { this = call.getIdentifier() }
override MethodCallExpr getCall() { result = call } override MethodCallExpr getCall() { result = call }
} }

View File

@@ -464,7 +464,7 @@ newtype TNode =
e = e =
[ [
any(IndexExprCfgNode i).getBase(), // any(IndexExprCfgNode i).getBase(), //
any(FieldExprCfgNode access).getExpr(), // any(FieldExprCfgNode access).getContainer(), //
any(TryExprCfgNode try).getExpr(), // any(TryExprCfgNode try).getExpr(), //
any(PrefixExprCfgNode pe | pe.getOperatorName() = "*").getExpr(), // any(PrefixExprCfgNode pe | pe.getOperatorName() = "*").getExpr(), //
any(AwaitExprCfgNode a).getExpr(), any(MethodCallExprCfgNode mc).getReceiver(), // any(AwaitExprCfgNode a).getExpr(), any(MethodCallExprCfgNode mc).getReceiver(), //

View File

@@ -30,8 +30,8 @@ module Impl {
override string toStringImpl() { override string toStringImpl() {
exists(string abbr, string name | exists(string abbr, string name |
abbr = this.getExpr().toAbbreviatedString() and abbr = this.getContainer().toAbbreviatedString() and
name = this.getNameRef().getText() and name = this.getIdentifier().getText() and
if abbr = "..." then result = "... ." + name else result = abbr + "." + name if abbr = "..." then result = "... ." + name else result = abbr + "." + name
) )
} }

View File

@@ -46,7 +46,7 @@ module Impl {
exists(string base, string separator | exists(string base, string separator |
base = this.getReceiver().toAbbreviatedString() and base = this.getReceiver().toAbbreviatedString() and
(if base = "..." then separator = " ." else separator = ".") and (if base = "..." then separator = " ." else separator = ".") and
result = base + separator + this.getNameRef().toStringImpl() + "(...)" result = base + separator + this.getIdentifier().toStringImpl() + "(...)"
) )
} }
} }

View File

@@ -39,7 +39,7 @@ module Impl {
* Gets the text of this path, if it exists. * Gets the text of this path, if it exists.
*/ */
pragma[nomagic] pragma[nomagic]
string getText() { result = this.getSegment().getNameRef().getText() } string getText() { result = this.getSegment().getIdentifier().getText() }
} }
/** A simple identifier path. */ /** A simple identifier path. */
@@ -54,7 +54,7 @@ module Impl {
not ps.hasParenthesizedArgList() and not ps.hasParenthesizedArgList() and
not ps.hasTypeRepr() and not ps.hasTypeRepr() and
not ps.hasReturnTypeSyntax() and not ps.hasReturnTypeSyntax() and
name = ps.getNameRef().getText() name = ps.getIdentifier().getText()
) )
} }

View File

@@ -24,7 +24,7 @@ module Impl {
private string toAbbreviatedStringPart(int index) { private string toAbbreviatedStringPart(int index) {
index = 0 and index = 0 and
if this.hasTypeRepr() then result = "<...>" else result = this.getNameRef().getText() if this.hasTypeRepr() then result = "<...>" else result = this.getIdentifier().getText()
or or
index = 1 and result = this.getGenericArgList().toAbbreviatedString() index = 1 and result = this.getGenericArgList().toAbbreviatedString()
} }

View File

@@ -25,9 +25,9 @@ module Impl {
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) } override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) { private string toStringPart(int index) {
index = 0 and result = this.getNameRef().getText() index = 0 and result = this.getIdentifier().getText()
or or
index = 1 and this.hasNameRef() and result = ": " index = 1 and this.hasIdentifier() and result = ": "
or or
index = 2 and index = 2 and
result = this.getExpr().toAbbreviatedString() result = this.getExpr().toAbbreviatedString()
@@ -44,9 +44,9 @@ module Impl {
* ``` * ```
*/ */
string getFieldName() { string getFieldName() {
result = this.getNameRef().getText() result = this.getIdentifier().getText()
or or
not this.hasNameRef() and not this.hasIdentifier() and
result = this.getExpr().(PathExpr).getPath().(PathImpl::IdentPath).getName() result = this.getExpr().(PathExpr).getPath().(PathImpl::IdentPath).getName()
} }
} }

View File

@@ -25,7 +25,7 @@ module Impl {
/** Gets the record field named `name`, if any. */ /** Gets the record field named `name`, if any. */
pragma[nomagic] pragma[nomagic]
StructField getStructField(string name) { StructField getStructField(string name) {
result = this.getFieldList().(RecordFieldList).getAField() and result = this.getFieldList().(StructFieldList).getAField() and
result.getName().getText() = name result.getName().getText() = name
} }

View File

@@ -24,9 +24,9 @@ module Impl {
override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) } override string toStringImpl() { result = concat(int i | | this.toStringPart(i) order by i) }
private string toStringPart(int index) { private string toStringPart(int index) {
index = 0 and result = this.getNameRef().getText() index = 0 and result = this.getIdentifier().getText()
or or
index = 1 and this.hasNameRef() and result = ": " index = 1 and this.hasIdentifier() and result = ": "
or or
index = 2 and index = 2 and
result = this.getPat().toAbbreviatedString() result = this.getPat().toAbbreviatedString()
@@ -43,9 +43,9 @@ module Impl {
* ``` * ```
*/ */
string getFieldName() { string getFieldName() {
result = this.getNameRef().getText() result = this.getIdentifier().getText()
or or
not this.hasNameRef() and not this.hasIdentifier() and
result = this.getPat().(IdentPat).getName().getText() result = this.getPat().(IdentPat).getName().getText()
} }
} }

View File

@@ -25,7 +25,7 @@ module Impl {
/** Gets the record field named `name`, if any. */ /** Gets the record field named `name`, if any. */
pragma[nomagic] pragma[nomagic]
StructField getStructField(string name) { StructField getStructField(string name) {
result = this.getFieldList().(RecordFieldList).getAField() and result = this.getFieldList().(StructFieldList).getAField() and
result.getName().getText() = name result.getName().getText() = name
} }

View File

@@ -39,7 +39,7 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
.(PathTypeRepr) .(PathTypeRepr)
.getPath() .getPath()
.getSegment() .getSegment()
.getNameRef() .getIdentifier()
.getText() .getText()
) and ) and
algorithmName = simplifyAlgorithmName(rawAlgorithmName) algorithmName = simplifyAlgorithmName(rawAlgorithmName)

View File

@@ -9,7 +9,7 @@ final class CloneCallable extends SummarizedCallable::Range {
// NOTE: The function target may not exist in the database, so we base this // NOTE: The function target may not exist in the database, so we base this
// on method calls. // on method calls.
exists(MethodCallExpr c | exists(MethodCallExpr c |
c.getNameRef().getText() = "clone" and c.getIdentifier().getText() = "clone" and
c.getArgList().getNumberOfArgs() = 0 and c.getArgList().getNumberOfArgs() = 0 and
this = c.getResolvedCrateOrigin() + "::_::" + c.getResolvedPath() this = c.getResolvedCrateOrigin() + "::_::" + c.getResolvedPath()
) )

View File

@@ -312,7 +312,7 @@ private class VariantItemNode extends ItemNode instanceof Variant {
override string getName() { result = Variant.super.getName().getText() } override string getName() { result = Variant.super.getName().getText() }
override Namespace getNamespace() { override Namespace getNamespace() {
if super.getFieldList() instanceof RecordFieldList then result.isType() else result.isValue() if super.getFieldList() instanceof StructFieldList then result.isType() else result.isValue()
} }
override TypeParam getTypeParam(int i) { override TypeParam getTypeParam(int i) {
@@ -471,7 +471,7 @@ private class StructItemNode extends ItemNode instanceof Struct {
override Namespace getNamespace() { override Namespace getNamespace() {
result.isType() // the struct itself result.isType() // the struct itself
or or
not super.getFieldList() instanceof RecordFieldList and not super.getFieldList() instanceof StructFieldList and
result.isValue() // the constructor result.isValue() // the constructor
} }

View File

@@ -764,7 +764,7 @@ private module FieldExprMatchingInput implements MatchingInputSig {
Type getTypeArgument(TypeArgumentPosition apos, TypePath path) { none() } Type getTypeArgument(TypeArgumentPosition apos, TypePath path) { none() }
AstNode getNodeAt(AccessPosition apos) { AstNode getNodeAt(AccessPosition apos) {
result = this.getExpr() and result = this.getContainer() and
apos.isSelf() apos.isSelf()
or or
result = this and result = this and
@@ -903,7 +903,7 @@ private module Cached {
pragma[nomagic] pragma[nomagic]
private Type getMethodCallExprLookupType(MethodCallExpr mce, string name) { private Type getMethodCallExprLookupType(MethodCallExpr mce, string name) {
result = getLookupType(mce.getReceiver()) and result = getLookupType(mce.getReceiver()) and
name = mce.getNameRef().getText() name = mce.getIdentifier().getText()
} }
/** /**
@@ -916,8 +916,8 @@ private module Cached {
pragma[nomagic] pragma[nomagic]
private Type getFieldExprLookupType(FieldExpr fe, string name) { private Type getFieldExprLookupType(FieldExpr fe, string name) {
result = getLookupType(fe.getExpr()) and result = getLookupType(fe.getContainer()) and
name = fe.getNameRef().getText() name = fe.getIdentifier().getText()
} }
/** /**

View File

@@ -64,7 +64,7 @@ private class RegexInjectionDefaultBarrier extends RegexInjectionBarrier {
.(PathExpr) .(PathExpr)
.getPath() .getPath()
.getSegment() .getSegment()
.getNameRef() .getIdentifier()
.getText() = "escape" .getText() = "escape"
} }
} }