Skip to content

Commit f539c99

Browse files
committed
temp
1 parent ce35990 commit f539c99

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

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

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,16 @@ private predicate isPanicMacroCall(MacroExpr me) {
268268
me.getMacroCall().resolveMacro().(MacroRules).getName().getText() = "panic"
269269
}
270270

271-
private Type inferCertainStructExprType(StructExpr se, TypePath path) {
272-
result = se.getPath().(TypeMention).getTypeAt(path)
273-
}
271+
/** Module for inferring certain type information. */
272+
module CertainTypeInference {
273+
// todo: remove module wrapper
274+
Type inferCertainStructExprType(StructExpr se, TypePath path) {
275+
result = se.getPath().(TypeMention).getTypeAt(path)
276+
}
274277

275-
private Type inferCertainStructPatType(StructPat sp, TypePath path) {
276-
result = sp.getPath().(TypeMention).getTypeAt(path)
278+
Type inferCertainStructPatType(StructPat sp, TypePath path) {
279+
result = sp.getPath().(TypeMention).getTypeAt(path)
280+
}
277281
}
278282

279283
private Type inferAssignmentOperationType(AstNode n, TypePath path) {
@@ -305,6 +309,7 @@ private Struct getRangeType(RangeExpr re) {
305309

306310
pragma[nomagic]
307311
private TupleType inferTupleRootType(AstNode n) {
312+
// `typeEquality` handles the non-root cases
308313
result.getArity() = [n.(TupleExpr).getNumberOfFields(), n.(TuplePat).getTupleArity()]
309314
}
310315

@@ -386,6 +391,13 @@ private class NonAssocCallExpr extends CallExpr {
386391
}
387392
}
388393

394+
/**
395+
* Provides functionality related to context-based typing of calls.
396+
*/
397+
private module ContextTyping {
398+
// todo: remove
399+
}
400+
389401
/**
390402
* Holds if the type path `path` pointing to `type` is stripped of any leading
391403
* complex root type allowed for `self` parameters, such as `&`, `Box`, `Rc`,
@@ -1847,6 +1859,21 @@ private module AssocFunctionResolution {
18471859
}
18481860
}
18491861

1862+
/**
1863+
* A matching configuration for resolving types of function call expressions
1864+
* like `foo.bar(baz)` and `Foo::bar(baz)`.
1865+
*/
1866+
private module FunctionCallMatchingInput {
1867+
// todo: remove
1868+
}
1869+
1870+
/**
1871+
* A matching configuration for resolving types of operations like `a + b`.
1872+
*/
1873+
private module OperationMatchingInput {
1874+
// todo: remove
1875+
}
1876+
18501877
pragma[nomagic]
18511878
private Type getFieldExprLookupType(FieldExpr fe, string name, DerefChain derefChain) {
18521879
exists(TypePath path |
@@ -2167,6 +2194,7 @@ private TupleType inferArgList(ArgList args, TypePath path) {
21672194

21682195
cached
21692196
private module Cached {
2197+
// todo: remove module wrapper
21702198
/** Holds if `n` is implicitly dereferenced and/or borrowed. */
21712199
cached
21722200
predicate implicitDerefChainBorrow(Expr e, DerefChain derefChain, boolean borrow) {
@@ -2993,9 +3021,9 @@ private module Input3 implements InputSig3 {
29933021
result = inferRefExprType(n) and
29943022
path.isEmpty()
29953023
or
2996-
result = inferCertainStructExprType(n, path)
3024+
result = CertainTypeInference::inferCertainStructExprType(n, path)
29973025
or
2998-
result = inferCertainStructPatType(n, path)
3026+
result = CertainTypeInference::inferCertainStructPatType(n, path)
29993027
or
30003028
result = inferRangeExprType(n) and
30013029
path.isEmpty()

0 commit comments

Comments
 (0)