Skip to content

Commit e4646e3

Browse files
committed
wip2
1 parent 84be802 commit e4646e3

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ private module AssocFunctionResolution {
16991699
exists(AssocFunctionType selfType |
17001700
ArgIsInstantiationOfSelfParam::argIsInstantiationOf(this, i, selfPos, derefChain, borrow,
17011701
selfType) and
1702-
CallArgsAreInstantiationsOf::argsAreNotInstantiationsOf(this, i, _) and
1702+
CallArgsAreInstantiationsOf::argsAreNotInstantiationsOf(this, i) and
17031703
root = selfType.getTypeAt(TypePath::nil())
17041704
)
17051705
}
@@ -2297,7 +2297,7 @@ private module AssocFunctionResolution {
22972297
}
22982298

22992299
/** A call with a dereference chain and a potential borrow. */
2300-
private class AssocFunctionCallCand extends MkAssocFunctionCallCand {
2300+
final private class AssocFunctionCallCand extends MkAssocFunctionCallCand {
23012301
AssocFunctionCall afc_;
23022302
FunctionPosition selfPos;
23032303
FunctionPosition selfPosAdj;
@@ -2394,7 +2394,7 @@ private module AssocFunctionResolution {
23942394
result = this.resolveCallTargetCand(i) and
23952395
not FunctionOverloading::functionResolutionDependsOnArgument(i, result, _, _)
23962396
or
2397-
CallArgsAreInstantiationsOf::argsAreInstantiationsOf(afc_, i, result)
2397+
CallArgsAreInstantiationsOf::argsAreInstantiationsOf(this, i, result)
23982398
}
23992399

24002400
string toString() {
@@ -2621,21 +2621,25 @@ private module AssocFunctionResolution {
26212621
FunctionOverloading::functionResolutionDependsOnArgument(i, f, traitTp, pos)
26222622
}
26232623

2624-
final private class AssocFunctionCallFinal = AssocFunctionCall;
2625-
2626-
class Call extends AssocFunctionCallFinal {
2627-
Type getArgType(FunctionPosition pos, TypePath path) { result = this.getTypeAt(pos, path) }
2624+
class Call extends AssocFunctionCallCand {
2625+
Type getArgType(FunctionPosition pos, TypePath path) {
2626+
result = this.getAssocFunctionCall().getTypeAt(pos, path)
2627+
}
26282628

26292629
predicate hasTargetCand(ImplOrTraitItemNode i, Function f) {
2630-
f =
2631-
any(AssocFunctionCallCand afcc | afcc = MkAssocFunctionCallCand(this, _, _, _, _))
2632-
.resolveCallTargetCand(i)
2630+
f = this.resolveCallTargetCand(i)
26332631
}
26342632
}
26352633
}
26362634

2637-
private module CallArgsAreInstantiationsOf =
2638-
ArgsAreInstantiationsOf<CallArgsAreInstantiationsOfInput>;
2635+
private module CallArgsAreInstantiationsOf {
2636+
import ArgsAreInstantiationsOf<CallArgsAreInstantiationsOfInput>
2637+
2638+
pragma[nomagic]
2639+
predicate argsAreNotInstantiationsOf(AssocFunctionCall afc, ImplOrTraitItemNode i) {
2640+
argsAreNotInstantiationsOf(MkAssocFunctionCallCand(afc, _, _, _, _), i, _)
2641+
}
2642+
}
26392643
}
26402644

26412645
/**
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
multipleResolvedTargets
2-
| test.rs:389:30:389:67 | pinned.poll_read(...) |
3-
| test.rs:416:26:416:54 | pinned.poll_fill_buf(...) |
4-
| test.rs:423:27:423:71 | ... .poll_fill_buf(...) |
5-
| test.rs:447:30:447:67 | pinned.poll_read(...) |
6-
| test.rs:470:26:470:54 | pinned.poll_fill_buf(...) |

0 commit comments

Comments
 (0)