Skip to content

Commit ae18ff7

Browse files
committed
wip
1 parent d9f3769 commit ae18ff7

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,32 @@ private module AssocFunctionResolution {
18581858
}
18591859
}
18601860

1861+
pragma[nomagic]
1862+
private Type inferFunctionCallType0(
1863+
FunctionCallMatchingInput::Access call, FunctionPosition pos, AstNode n, DerefChain derefChain,
1864+
BorrowKind borrow, TypePath path
1865+
) {
1866+
exists(TypePath path0 |
1867+
n = call.getNodeAt(pos) and
1868+
exists(string derefChainBorrow |
1869+
FunctionCallMatchingInput::decodeDerefChainBorrow(derefChainBorrow, derefChain, borrow)
1870+
|
1871+
result = FunctionCallMatching::inferAccessType(call, derefChainBorrow, pos, path0)
1872+
or
1873+
call.hasUnknownTypeAt(derefChainBorrow, pos, path0) and
1874+
result = TUnknownType()
1875+
)
1876+
|
1877+
if
1878+
// index expression `x[i]` desugars to `*x.index(i)`, so we must account for
1879+
// the implicit deref
1880+
pos.isReturn() and
1881+
call instanceof IndexExpr
1882+
then path0.isCons(getRefTypeParameter(_), path)
1883+
else path = path0
1884+
)
1885+
}
1886+
18611887
pragma[nomagic]
18621888
private Type getFieldExprLookupType(FieldExpr fe, string name, DerefChain derefChain) {
18631889
exists(TypePath path |

0 commit comments

Comments
 (0)