Skip to content

Commit e215bef

Browse files
committed
Rust: Also apply adjustedAccessType in RelevantAccess
1 parent 75caa18 commit e215bef

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

shared/typeinference/codeql/typeinference/internal/TypeInference.qll

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -979,17 +979,18 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
979979

980980
private module AccessConstraint {
981981
predicate relevantAccessConstraint(
982-
Access a, AccessPosition apos, TypePath path, Type constraint
982+
Access a, Declaration target, AccessPosition apos, TypePath path, Type constraint
983983
) {
984984
exists(DeclarationPosition dpos |
985985
accessDeclarationPositionMatch(apos, dpos) and
986-
typeParameterConstraintHasTypeParameter(a.getTarget(), dpos, path, _, constraint, _, _)
986+
target = a.getTarget() and
987+
typeParameterConstraintHasTypeParameter(target, dpos, path, _, constraint, _, _)
987988
)
988989
}
989990

990991
private newtype TRelevantAccess =
991-
MkRelevantAccess(Access a, AccessPosition apos, TypePath path) {
992-
relevantAccessConstraint(a, apos, path, _)
992+
MkRelevantAccess(Access a, Declaration target, AccessPosition apos, TypePath path) {
993+
relevantAccessConstraint(a, target, apos, path, _)
993994
}
994995

995996
/**
@@ -998,19 +999,20 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
998999
*/
9991000
private class RelevantAccess extends MkRelevantAccess {
10001001
Access a;
1002+
Declaration target;
10011003
AccessPosition apos;
10021004
TypePath path;
10031005

1004-
RelevantAccess() { this = MkRelevantAccess(a, apos, path) }
1006+
RelevantAccess() { this = MkRelevantAccess(a, target, apos, path) }
10051007

10061008
Type getTypeAt(TypePath suffix) {
1007-
a.getInferredType(apos, path.appendInverse(suffix)) = result
1009+
adjustedAccessType(a, apos, target, path.appendInverse(suffix), result)
10081010
}
10091011

10101012
/** Holds if this relevant access has the type `type` and should satisfy `constraint`. */
10111013
predicate hasTypeConstraint(Type type, Type constraint) {
1012-
type = a.getInferredType(apos, path) and
1013-
relevantAccessConstraint(a, apos, path, constraint)
1014+
adjustedAccessType(a, apos, target, path, type) and
1015+
relevantAccessConstraint(a, target, apos, path, constraint)
10141016
}
10151017

10161018
string toString() {
@@ -1075,7 +1077,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
10751077
RelevantAccess at, TypeAbstraction abs, TypeMention sub, Type t0, TypePath prefix0,
10761078
TypeMention constraintMention
10771079
|
1078-
at = MkRelevantAccess(a, apos, prefix) and
1080+
at = MkRelevantAccess(a, _, apos, prefix) and
10791081
hasConstraintMention(at, abs, sub, constraint, constraintMention) and
10801082
conditionSatisfiesConstraintTypeAt(abs, sub, constraintMention, prefix0, t0)
10811083
|

0 commit comments

Comments
 (0)