Skip to content

Commit 781be8d

Browse files
committed
Rust: Revert "Rust: Handle functions in dependencies not having parameters"
This reverts commit 0699028.
1 parent 152ad2e commit 781be8d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -965,25 +965,20 @@ private module Cached {
965965

966966
/** Holds if a method for `type` with the name `name` and the arity `arity` exists in `impl`. */
967967
pragma[nomagic]
968-
private predicate methodCandidate(Type type, string name, Impl impl, Function f) {
968+
private predicate methodCandidate(Type type, string name, int arity, Impl impl) {
969969
type = impl.(ImplTypeAbstraction).getSelfTy().(TypeReprMention).resolveType() and
970-
f = impl.(ImplItemNode).getASuccessor(name)
970+
exists(Function f |
971+
f = impl.(ImplItemNode).getASuccessor(name) and
972+
f.getParamList().hasSelfParam() and
973+
arity = f.getParamList().getNumberOfParams()
974+
)
971975
}
972976

973977
private module IsInstantiationOfInput implements IsInstantiationOfSig<ReceiverExpr> {
974978
predicate potentialInstantiationOf(ReceiverExpr receiver, TypeAbstraction impl, TypeMention sub) {
975-
exists(Function method |
976-
methodCandidate(receiver.resolveTypeAt(TypePath::nil()), receiver.getField(), impl, method) and
977-
(
978-
method.getParamList().getNumberOfParams() = receiver.getNumberOfArgs() and
979-
method.getParamList().hasSelfParam()
980-
or
981-
// TODO: Once parameter lists for functions in dependencies are
982-
// extracted correctly we should check arity for those as well.
983-
not method.fromSource()
984-
) and
985-
sub = impl.(ImplTypeAbstraction).getSelfTy()
986-
)
979+
methodCandidate(receiver.resolveTypeAt(TypePath::nil()), receiver.getField(),
980+
receiver.getNumberOfArgs(), impl) and
981+
sub = impl.(ImplTypeAbstraction).getSelfTy()
987982
}
988983
}
989984

0 commit comments

Comments
 (0)