Skip to content

Commit 7573276

Browse files
committed
wip
1 parent 1c1c031 commit 7573276

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
@@ -1164,9 +1164,10 @@ private module MethodCallResolution {
11641164

11651165
pragma[nomagic]
11661166
private predicate methodCallTraitCandidate(Element mc, Trait trait) {
1167-
exists(string name, int arity |
1168-
mc.(MethodCall).isMethodCall(name, arity) and
1167+
exists(string name, int arity | mc.(MethodCall).isMethodCall(name, arity) |
11691168
traitMethodInfo(name, arity, trait)
1169+
or
1170+
methodInfo(_, name, arity, trait, _, _, _, _)
11701171
)
11711172
}
11721173

@@ -1202,15 +1203,29 @@ private module MethodCallResolution {
12021203
mc.isMethodCall(name, arity) and
12031204
methodInfo(_, name, arity, i, self, rootType, selfRootPath, selfRootType)
12041205
|
1205-
not i.(Impl).hasTrait()
1206+
i =
1207+
any(Impl impl |
1208+
not impl.hasTrait()
1209+
or
1210+
methodCallVisibleImplTraitCandidate(mc, i)
1211+
)
12061212
or
1207-
methodCallVisibleImplTraitCandidate(mc, i)
1213+
methodCallVisibleTraitCandidate(mc, i)
12081214
or
12091215
mc instanceof IndexExpr and
12101216
i.(ImplItemNode).resolveTraitTy() instanceof IndexTrait
12111217
)
12121218
}
12131219

1220+
private int countmethodCallCandidate(MethodCall mc) {
1221+
result = strictcount(ImplOrTraitItemNode i | methodCallCandidate(mc, i, _, _, _, _))
1222+
}
1223+
1224+
private predicate countmethodCallMaxCandidate(MethodCall mc, ImplOrTraitItemNode i) {
1225+
methodCallCandidate(mc, i, _, _, _, _) and
1226+
countmethodCallCandidate(mc) = max(countmethodCallCandidate(_))
1227+
}
1228+
12141229
/**
12151230
* A method call.
12161231
*
@@ -3106,7 +3121,7 @@ private module Debug {
31063121
// filepath.matches("%/crates/wdk-macros/src/lib.rs") and
31073122
// endline = [255 .. 256]
31083123
filepath.matches("%/main.rs") and
3109-
startline = 286
3124+
startline = 550
31103125
)
31113126
}
31123127

0 commit comments

Comments
 (0)