Skip to content

Commit 832546f

Browse files
committed
wip
1 parent 4f84362 commit 832546f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,10 @@ private module MethodCallResolution {
11521152

11531153
pragma[nomagic]
11541154
private predicate methodCallTraitCandidate(Element mc, Trait trait) {
1155-
exists(string name, int arity |
1156-
mc.(MethodCall).isMethodCall(name, arity) and
1155+
exists(string name, int arity | mc.(MethodCall).isMethodCall(name, arity) |
11571156
traitMethodInfo(name, arity, trait)
1157+
or
1158+
methodInfo(_, name, arity, trait, _, _, _, _)
11581159
)
11591160
}
11601161

@@ -1190,15 +1191,29 @@ private module MethodCallResolution {
11901191
mc.isMethodCall(name, arity) and
11911192
methodInfo(_, name, arity, i, self, rootType, selfRootPath, selfRootType)
11921193
|
1193-
not i.(Impl).hasTrait()
1194+
i =
1195+
any(Impl impl |
1196+
not impl.hasTrait()
1197+
or
1198+
methodCallVisibleImplTraitCandidate(mc, i)
1199+
)
11941200
or
1195-
methodCallVisibleImplTraitCandidate(mc, i)
1201+
methodCallVisibleTraitCandidate(mc, i)
11961202
or
11971203
mc instanceof IndexExpr and
11981204
i.(ImplItemNode).resolveTraitTy() instanceof IndexTrait
11991205
)
12001206
}
12011207

1208+
private int countmethodCallCandidate(MethodCall mc) {
1209+
result = strictcount(ImplOrTraitItemNode i | methodCallCandidate(mc, i, _, _, _, _))
1210+
}
1211+
1212+
private predicate countmethodCallMaxCandidate(MethodCall mc, ImplOrTraitItemNode i) {
1213+
methodCallCandidate(mc, i, _, _, _, _) and
1214+
countmethodCallCandidate(mc) = max(countmethodCallCandidate(_))
1215+
}
1216+
12021217
/**
12031218
* A method call.
12041219
*
@@ -3094,7 +3109,7 @@ private module Debug {
30943109
// filepath.matches("%/crates/wdk-macros/src/lib.rs") and
30953110
// endline = [255 .. 256]
30963111
filepath.matches("%/main.rs") and
3097-
startline = 286
3112+
startline = 550
30983113
)
30993114
}
31003115

0 commit comments

Comments
 (0)