Skip to content

Commit aae6cd9

Browse files
committed
Address review comments
1 parent 3c6a757 commit aae6cd9

File tree

3 files changed

+79
-78
lines changed

3 files changed

+79
-78
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/Node.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ final class ExprArgumentNode extends ArgumentNode, ExprNode {
230230
ExprArgumentNode() {
231231
isArgumentForCall(n, call_, pos_) and
232232
not TypeInference::implicitDeref(n) and
233-
not TypeInference::implicitBorrow(n)
233+
not TypeInference::implicitBorrow(n, _)
234234
}
235235

236236
override predicate isArgumentOf(DataFlowCall call, RustDataFlow::ArgumentPosition pos) {
@@ -579,7 +579,7 @@ newtype TNode =
579579
TypeInference::implicitDeref(n) and
580580
borrow = false
581581
or
582-
TypeInference::implicitBorrow(n) and
582+
TypeInference::implicitBorrow(n, _) and
583583
borrow = true
584584
} or
585585
TDerefOutNode(DerefExpr de, Boolean isPost) or

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,31 +226,28 @@ TypeParamTypeParameter getArrayTypeParameter() {
226226

227227
abstract class RefType extends StructType { }
228228

229-
pragma[nomagic]
230-
TypeParamTypeParameter getRefTypeParameter() {
231-
result = any(RefType t).getPositionalTypeParameter(0)
232-
}
233-
234229
class RefMutType extends RefType {
235230
RefMutType() { this.getStruct() instanceof Builtins::RefMutType }
236231

237232
override string toString() { result = "&mut" }
238233
}
239234

240-
pragma[nomagic]
241-
TypeParamTypeParameter getRefMutTypeParameter() {
242-
result = any(RefMutType t).getPositionalTypeParameter(0)
243-
}
244-
245235
class RefSharedType extends RefType {
246236
RefSharedType() { this.getStruct() instanceof Builtins::RefSharedType }
247237

248238
override string toString() { result = "&" }
249239
}
250240

251241
pragma[nomagic]
252-
TypeParamTypeParameter getRefSharedTypeParameter() {
253-
result = any(RefSharedType t).getPositionalTypeParameter(0)
242+
RefType getRefType(boolean isMutable) {
243+
isMutable = true and result instanceof RefMutType
244+
or
245+
isMutable = false and result instanceof RefSharedType
246+
}
247+
248+
pragma[nomagic]
249+
TypeParamTypeParameter getRefTypeParameter(boolean isMutable) {
250+
result = getRefType(isMutable).getPositionalTypeParameter(0)
254251
}
255252

256253
/**

0 commit comments

Comments
 (0)