Skip to content

Commit 409f7fb

Browse files
committed
Address review comments
1 parent 0e885e9 commit 409f7fb

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ private module MethodResolution {
12301230
ReceiverIsNotInstantiationOfBlanketLikeSelfParam::argIsNotInstantiationOf(MkMethodCallCand(this,
12311231
derefChain, borrow), impl, _)
12321232
or
1233-
ReceiverSatisfiesBlanketLikeConstraint::satisfiesNotBlanketConstraint(MkMethodCallCand(this,
1233+
ReceiverSatisfiesBlanketLikeConstraint::dissatisfiesBlanketConstraint(MkMethodCallCand(this,
12341234
derefChain, borrow), impl)
12351235
}
12361236

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ module SatisfiesBlanketConstraint<
138138
* constraint of `impl`.
139139
*/
140140
pragma[nomagic]
141-
predicate satisfiesNotBlanketConstraint(ArgumentType at, ImplItemNode impl) {
141+
predicate dissatisfiesBlanketConstraint(ArgumentType at, ImplItemNode impl) {
142142
exists(ArgumentTypeAndBlanketOffset ato, Trait traitBound |
143143
ato = MkArgumentTypeAndBlanketOffset(at, _) and
144144
SatisfiesBlanketConstraintInput::relevantConstraint(ato, impl, traitBound) and
145-
SatisfiesBlanketConstraint::satisfiesNotConstraint(ato, TTrait(traitBound))
145+
SatisfiesBlanketConstraint::dissatisfiesConstraint(ato, TTrait(traitBound))
146146
)
147147
}
148148
}

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,13 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
705705
/**
706706
* Holds if `app` is _not_ a possible instantiation of `constraint`.
707707
*
708-
* This is a monotonic approximation of `not isInstantiationOf(app, abs, constraint)`;
709-
* if, for example, `app` has two different types `t1` and `t2` at the same type path,
710-
* and `t1` satisfies `constraint` while `t2` does not, then both `isInstantiationOf`
711-
* and `isNotInstantiationOf` will hold.
708+
* This is an approximation of `not isInstantiationOf(app, abs, constraint)`, but
709+
* defined without a negative occurrence of `isInstantiationOf`.
710+
*
711+
* Due to the approximation, both `isInstantiationOf` and `isNotInstantiationOf`
712+
* can hold for the same values. For example, if `app` has two different types `t1`
713+
* and `t2` at the same type path, and `t1` satisfies `constraint` while `t2` does
714+
* not, then both `isInstantiationOf` and `isNotInstantiationOf` will hold.
712715
*
713716
* Dually, if `app` does not have a type at a required type path, then neither
714717
* `isInstantiationOf` nor `isNotInstantiationOf` will hold.
@@ -1008,6 +1011,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
10081011

10091012
/**
10101013
* Holds if `tt` does not satisfy `constraint`.
1014+
*
1015+
* This predicate is an approximation of `not hasConstraintMention(tt, constraint)`.
10111016
*/
10121017
pragma[nomagic]
10131018
private predicate hasNotConstraintMention(HasTypeTree tt, Type constraint) {
@@ -1085,16 +1090,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
10851090
/**
10861091
* Holds if the type tree at `tt` does _not_ satisfy the constraint `constraint`.
10871092
*
1088-
* This is a monotonic approximation of `not satisfiesConstraintType(tt, constraint, _, _)`;
1089-
* if, for example, `tt` has two different types `t1` and `t2`, and `t1` satisfies
1090-
* `constraint` while `t2` does not, then both `satisfiesConstraintType` and
1091-
* `satisfiesNotConstraint` will hold.
1093+
* This is an approximation of `not satisfiesConstraintType(tt, constraint, _, _)`,
1094+
* but defined without a negative occurrence of `satisfiesConstraintType`.
1095+
*
1096+
* Due to the approximation, both `satisfiesConstraintType` and `dissatisfiesConstraint`
1097+
* can hold for the same values. For example, if `tt` has two different types `t1`
1098+
* and `t2`, and `t1` satisfies `constraint` while `t2` does not, then both
1099+
* `satisfiesConstraintType` and `dissatisfiesConstraint` will hold.
10921100
*
10931101
* Dually, if `tt` does not have a type, then neither `satisfiesConstraintType` nor
1094-
* `satisfiesNotConstraint` will hold.
1102+
* `dissatisfiesConstraint` will hold.
10951103
*/
10961104
pragma[nomagic]
1097-
predicate satisfiesNotConstraint(HasTypeTree tt, Type constraint) {
1105+
predicate dissatisfiesConstraint(HasTypeTree tt, Type constraint) {
10981106
hasNotConstraintMention(tt, constraint) and
10991107
exists(Type t |
11001108
hasTypeConstraint(tt, t, constraint) and

0 commit comments

Comments
 (0)