Skip to content

Commit 70c6086

Browse files
committed
Rust: Model ? as reading from Option and Result
1 parent b50834a commit 70c6086

File tree

4 files changed

+295
-261
lines changed

4 files changed

+295
-261
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,13 @@ module RustDataFlow implements InputSig<Location> {
884884
node1.asExpr() = access.getExpr() and
885885
node2.asExpr() = access
886886
)
887+
or
888+
exists(TryExprCfgNode try |
889+
node1.asExpr() = try.getExpr() and
890+
node2.asExpr() = try and
891+
c.(VariantPositionContent).getVariantCanonicalPath(0).getExtendedCanonicalPath() =
892+
["crate::option::Option::Some", "crate::result::Result::Ok"]
893+
)
887894
)
888895
or
889896
FlowSummaryImpl::Private::Steps::summaryReadStep(node1.(Node::FlowSummaryNode).getSummaryNode(),
@@ -1050,7 +1057,8 @@ private module Cached {
10501057
TSourceParameterNode(ParamBaseCfgNode p) or
10511058
TPatNode(PatCfgNode p) or
10521059
TExprPostUpdateNode(ExprCfgNode e) {
1053-
isArgumentForCall(e, _, _) or e = any(FieldExprCfgNode access).getExpr()
1060+
isArgumentForCall(e, _, _) or
1061+
e = [any(FieldExprCfgNode access).getExpr(), any(TryExprCfgNode try).getExpr()]
10541062
} or
10551063
TSsaNode(SsaImpl::DataFlowIntegration::SsaNode node) or
10561064
TFlowSummaryNode(FlowSummaryImpl::Private::SummaryNode sn)

0 commit comments

Comments
 (0)