Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CallableScopeTree extends StandardTree, PreOrderTree, PostOrderTree, Scope

override AstNode getChildNode(int i) {
i = 0 and
result = this.getParamList().getSelfParam()
result = this.getSelfParam()
or
result = this.getParam(i - 1)
or
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/lib/codeql/rust/elements/internal/CallImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module Impl {
f = resolvePath(path) and
path.getSegment().getIdentifier().getText() = methodName and
exists(SelfParam self |
self = f.getParamList().getSelfParam() and
self = f.getSelfParam() and
if self.isRef() then selfIsRef = true else selfIsRef = false
)
)
Expand Down
10 changes: 10 additions & 0 deletions rust/ql/lib/codeql/rust/elements/internal/CallableImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ module Impl {
*/
class Callable extends Generated::Callable {
override Param getParam(int index) { result = this.getParamList().getParam(index) }

/**
* Gets the self parameter of this callable, if it exists.
*/
SelfParam getSelfParam() { result = this.getParamList().getSelfParam() }

/**
* Holds if `getSelfParam()` exists.
*/
predicate hasSelfParam() { exists(this.getSelfParam()) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module Impl {
text = name.getText() and
// exclude self parameters from functions without a body as these are
// trait method declarations without implementations
not exists(Function f | not f.hasBody() and f.getParamList().getSelfParam() = sp)
not exists(Function f | not f.hasBody() and f.getSelfParam() = sp)
)
or
exists(IdentPat pat |
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/lib/codeql/rust/internal/CachedStages.qll
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module Stages {
or
exists(resolvePath(_))
or
exists(any(ItemNode i).getASuccessor(_, _))
exists(any(ItemNode i).getASuccessor(_, _, _))
or
exists(any(ImplOrTraitItemNode i).getASelfPath())
or
Expand Down
Loading