Skip to content
Merged
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
14 changes: 7 additions & 7 deletions rust/ql/lib/codeql/rust/internal/TypeInference.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,12 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
}

pragma[nomagic]
private Type getInferredSelfType(string derefChain, boolean borrow, TypePath path) {
result = this.getACandidateReceiverTypeAt(derefChain, borrow, path)
private Type getInferredSelfType(AccessPosition apos, string derefChainBorrow, TypePath path) {
exists(string derefChain, boolean borrow |
result = this.getACandidateReceiverTypeAt(derefChain, borrow, path) and
derefChainBorrow = encodeDerefChainBorrow(derefChain, borrow) and
apos.isSelf()
)
}

pragma[nomagic]
Expand All @@ -1839,11 +1843,7 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi

bindingset[derefChainBorrow]
Type getInferredType(string derefChainBorrow, AccessPosition apos, TypePath path) {
exists(string derefChain, boolean borrow |
derefChainBorrow = encodeDerefChainBorrow(derefChain, borrow) and
apos.isSelf() and
result = this.getInferredSelfType(derefChain, borrow, path)
)
result = this.getInferredSelfType(apos, derefChainBorrow, path)
or
result = this.getInferredNonSelfType(apos, path)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {

pragma[nomagic]
private predicate directTypeMatch0(
Access a, AccessEnvironment e, Declaration target, DeclarationPosition dpos,
Access a, DeclarationPosition dpos, AccessEnvironment e, Declaration target,
TypePath pathToTypeParam, TypeParameter tp
) {
not exists(getTypeArgument(a, target, tp, _)) and
Expand All @@ -1177,7 +1177,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
Access a, AccessEnvironment e, Declaration target, TypePath path, Type t, TypeParameter tp
) {
exists(AccessPosition apos, DeclarationPosition dpos, TypePath pathToTypeParam |
directTypeMatch0(a, e, target, dpos, pathToTypeParam, tp) and
directTypeMatch0(a, dpos, e, target, pathToTypeParam, tp) and
accessDeclarationPositionMatch(apos, dpos) and
t = a.getInferredType(e, apos, pathToTypeParam.appendInverse(path))
)
Expand Down Expand Up @@ -1269,7 +1269,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
}

private newtype TRelevantAccess =
MkRelevantAccess(Access a, AccessEnvironment e, AccessPosition apos, TypePath path) {
MkRelevantAccess(Access a, AccessPosition apos, AccessEnvironment e, TypePath path) {
relevantAccessConstraint(a, e, _, apos, path, _)
}

Expand All @@ -1279,11 +1279,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
*/
private class RelevantAccess extends MkRelevantAccess {
Access a;
AccessEnvironment e;
AccessPosition apos;
AccessEnvironment e;
TypePath path;

RelevantAccess() { this = MkRelevantAccess(a, e, apos, path) }
RelevantAccess() { this = MkRelevantAccess(a, apos, e, path) }

Type getTypeAt(TypePath suffix) {
result = a.getInferredType(e, apos, path.appendInverse(suffix))
Expand Down Expand Up @@ -1314,7 +1314,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
Type constraint, TypePath path, Type t
) {
exists(RelevantAccess ra |
ra = MkRelevantAccess(a, e, apos, prefix) and
ra = MkRelevantAccess(a, apos, e, prefix) and
SatisfiesConstraint<RelevantAccess, SatisfiesConstraintInput>::satisfiesConstraintType(ra,
constraint, path, t) and
constraint = ra.getConstraint(target)
Expand Down
Loading