mirror of
https://github.com/github/codeql.git
synced 2026-04-24 08:15:14 +02:00
Rust: Only adjust access type for method call expressions
This commit is contained in:
@@ -675,12 +675,13 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
|
||||
apos = dpos
|
||||
}
|
||||
|
||||
bindingset[apos, target, path, t]
|
||||
bindingset[a, apos, target, path, t]
|
||||
pragma[inline_late]
|
||||
predicate adjustAccessType(
|
||||
AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj, Type tAdj
|
||||
Access a, AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj,
|
||||
Type tAdj
|
||||
) {
|
||||
if apos.isSelf()
|
||||
if apos.isSelf() and a.receiverImplicitlyBorrowed()
|
||||
then
|
||||
exists(Type selfParamType |
|
||||
selfParamType = target.getParameterType(TSelfDeclarationPosition(), TypePath::nil())
|
||||
@@ -844,11 +845,13 @@ private module FieldExprMatchingInput implements MatchingInputSig {
|
||||
apos = dpos
|
||||
}
|
||||
|
||||
bindingset[apos, target, path, t]
|
||||
bindingset[a, apos, target, path, t]
|
||||
pragma[inline_late]
|
||||
predicate adjustAccessType(
|
||||
AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj, Type tAdj
|
||||
Access a, AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj,
|
||||
Type tAdj
|
||||
) {
|
||||
exists(a) and
|
||||
exists(target) and
|
||||
if apos.isSelf()
|
||||
then
|
||||
|
||||
@@ -847,9 +847,10 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
* the inferred type of `42` is `int`, but it should be adjusted to `int?`
|
||||
* when matching against `M`.
|
||||
*/
|
||||
bindingset[apos, target, path, t]
|
||||
bindingset[a, apos, target, path, t]
|
||||
default predicate adjustAccessType(
|
||||
AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj, Type tAdj
|
||||
Access a, AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj,
|
||||
Type tAdj
|
||||
) {
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
@@ -876,7 +877,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
target = a.getTarget() and
|
||||
exists(TypePath path0, Type t0 |
|
||||
t0 = a.getInferredType(apos, path0) and
|
||||
adjustAccessType(apos, target, path0, t0, path, t)
|
||||
adjustAccessType(a, apos, target, path0, t0, path, t)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user