Merge pull request #19717 from hvitved/rust/use-get-arg-param

Rust: Use `get(An){Arg,Param}` helper predicates
This commit is contained in:
Tom Hvitved
2025-06-10 18:48:51 +02:00
committed by GitHub
7 changed files with 10 additions and 10 deletions

View File

@@ -59,7 +59,7 @@ class BreakExprTargetChildMapping extends ParentAstNode, Expr {
}
class CallExprBaseChildMapping extends ParentAstNode, CallExprBase {
override predicate relevantChild(AstNode child) { child = this.getArgList().getAnArg() }
override predicate relevantChild(AstNode child) { child = this.getAnArg() }
}
class StructExprChildMapping extends ParentAstNode, StructExpr {

View File

@@ -87,7 +87,7 @@ class CallableScopeTree extends StandardTree, PreOrderTree, PostOrderTree, Scope
i = 0 and
result = this.getParamList().getSelfParam()
or
result = this.getParamList().getParam(i - 1)
result = this.getParam(i - 1)
or
i = this.getParamList().getNumberOfParams() + 1 and
result = this.getBody()
@@ -543,7 +543,7 @@ module ExprTrees {
class MethodCallExprTree extends StandardPostOrderTree, MethodCallExpr {
override AstNode getChildNode(int i) {
if i = 0 then result = this.getReceiver() else result = this.getArgList().getArg(i - 1)
if i = 0 then result = this.getReceiver() else result = this.getArg(i - 1)
}
}

View File

@@ -55,7 +55,7 @@ module Impl {
pragma[nomagic]
private PathResolution::ItemNode getResolvedFunctionAndPos(int pos) {
result = getResolvedFunction(this) and
exists(this.getArgList().getArg(pos))
exists(this.getArg(pos))
}
/**

View File

@@ -95,9 +95,9 @@ module Impl {
not text.charAt(0).isUppercase() and
// exclude parameters from functions without a body as these are trait method declarations
// without implementations
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = pat) and
not exists(Function f | not f.hasBody() and f.getAParam().getPat() = pat) and
// exclude parameters from function pointer types (e.g. `x` in `fn(x: i32) -> i32`)
not exists(FnPtrTypeRepr fp | fp.getParamList().getParam(_).getPat() = pat)
not exists(FnPtrTypeRepr fp | fp.getParamList().getAParam().getPat() = pat)
)
}

View File

@@ -352,7 +352,7 @@ class SelfTypeParameter extends TypeParameter, TSelfTypeParameter {
class ImplTraitTypeTypeParameter extends ImplTraitType, TypeParameter {
private Function function;
ImplTraitTypeTypeParameter() { impl = function.getParamList().getAParam().getTypeRepr() }
ImplTraitTypeTypeParameter() { impl = function.getAParam().getTypeRepr() }
override Function getFunction() { result = function }

View File

@@ -1100,7 +1100,7 @@ private module AwaitExprMatchingInput implements MatchingInputSig {
Type getDeclaredType(DeclarationPosition dpos, TypePath path) {
dpos.isSelf() and
result = this.getParamList().getParam(0).getTypeRepr().(TypeMention).resolveTypeAt(path)
result = this.getParam(0).getTypeRepr().(TypeMention).resolveTypeAt(path)
or
dpos.isOutput() and
result = this.getRetType().getTypeRepr().(TypeMention).resolveTypeAt(path)
@@ -1199,7 +1199,7 @@ private module MethodCall {
Expr receiver;
CallExprMethodCall() {
receiver = this.getArgList().getArg(0) and
receiver = this.getArg(0) and
exists(Path path, Function f |
path = this.getFunction().(PathExpr).getPath() and
f = resolvePath(path) and

View File

@@ -79,7 +79,7 @@ module ModelGeneratorCommonInput implements
bindingset[c]
string paramReturnNodeAsExactOutput(Callable c, DataFlowImpl::ParameterPosition pos) {
result = parameterExactAccess(c.getParamList().getParam(pos.getPosition()))
result = parameterExactAccess(c.getParam(pos.getPosition()))
or
pos.isSelf() and result = qualifierString()
}