Skip to content

Commit 6e54fa0

Browse files
committed
Rust: Simplify
1 parent 2ad8e2b commit 6e54fa0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,14 +1759,14 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
17591759
path = TypePath::cons(TRefTypeParameter(), suffix)
17601760
)
17611761
else (
1762-
not apos.asArgumentPosition().isSelf() and
1762+
not apos.isSelf() and
17631763
result = inferType(this.getNodeAt(apos), path)
17641764
)
17651765
}
17661766

17671767
pragma[nomagic]
17681768
Type getInferredType(string derefChainBorrow, AccessPosition apos, TypePath path) {
1769-
apos.asArgumentPosition().isSelf() and
1769+
apos.isSelf() and
17701770
result = this.getInferredSelfType(derefChainBorrow, path)
17711771
or
17721772
result = this.getInferredNonSelfType(apos, path) and
@@ -1813,19 +1813,19 @@ private Type inferMethodCallType(AstNode n, TypePath path) {
18131813
result = inferMethodCallType0(a, apos, n, derefChainBorrow, path0)
18141814
|
18151815
(
1816-
not apos.asArgumentPosition().isSelf()
1816+
not apos.isSelf()
18171817
or
18181818
derefChainBorrow = ";"
18191819
) and
18201820
path = path0
18211821
or
18221822
// adjust for implicit deref
1823-
apos.asArgumentPosition().isSelf() and
1823+
apos.isSelf() and
18241824
derefChainBorrow = ".ref;" and
18251825
path = TypePath::cons(TRefTypeParameter(), path0)
18261826
or
18271827
// adjust for implicit borrow
1828-
apos.asArgumentPosition().isSelf() and
1828+
apos.isSelf() and
18291829
derefChainBorrow = ";borrow" and
18301830
path0.isCons(TRefTypeParameter(), path)
18311831
)
@@ -1947,10 +1947,7 @@ private module NonMethodResolution {
19471947
}
19481948

19491949
AstNode getNodeAt(FunctionTypePosition pos) {
1950-
exists(ArgumentPosition apos |
1951-
apos = pos.asArgumentPosition() and
1952-
result = this.getArg(apos.asPosition())
1953-
)
1950+
result = this.getArg(pos.asPositional())
19541951
or
19551952
result = this and pos.isReturn()
19561953
}
@@ -2243,7 +2240,7 @@ private module NonMethodCallMatchingInput implements MatchingInputSig {
22432240

22442241
pragma[nomagic]
22452242
Type getInferredType(AccessPosition apos, TypePath path) {
2246-
apos.asArgumentPosition().isSelf() and
2243+
apos.isSelf() and
22472244
result = getCallExprTypeQualifier(this, path)
22482245
or
22492246
result = inferType(this.getNodeAt(apos), path)

0 commit comments

Comments
 (0)