mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Merge pull request #19717 from hvitved/rust/use-get-arg-param
Rust: Use `get(An){Arg,Param}` helper predicates
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user