Skip to content

Commit 6404f99

Browse files
committed
temp
1 parent ce35990 commit 6404f99

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

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

Lines changed: 27 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,13 @@ private module AssocFunctionResolution {
18471859
}
18481860
}
18491861

1862+
/**
1863+
* A matching configuration for resolving types of operations like `a + b`.
1864+
*/
1865+
private module OperationMatchingInput {
1866+
// todo: remove
1867+
}
1868+
18501869
pragma[nomagic]
18511870
private Type getFieldExprLookupType(FieldExpr fe, string name, DerefChain derefChain) {
18521871
exists(TypePath path |
@@ -2167,6 +2186,7 @@ private TupleType inferArgList(ArgList args, TypePath path) {
21672186

21682187
cached
21692188
private module Cached {
2189+
// todo: remove module wrapper
21702190
/** Holds if `n` is implicitly dereferenced and/or borrowed. */
21712191
cached
21722192
predicate implicitDerefChainBorrow(Expr e, DerefChain derefChain, boolean borrow) {
@@ -2993,9 +3013,9 @@ private module Input3 implements InputSig3 {
29933013
result = inferRefExprType(n) and
29943014
path.isEmpty()
29953015
or
2996-
result = inferCertainStructExprType(n, path)
3016+
result = CertainTypeInference::inferCertainStructExprType(n, path)
29973017
or
2998-
result = inferCertainStructPatType(n, path)
3018+
result = CertainTypeInference::inferCertainStructPatType(n, path)
29993019
or
30003020
result = inferRangeExprType(n) and
30013021
path.isEmpty()

0 commit comments

Comments
 (0)