@@ -623,6 +623,15 @@ private class StructFieldContent extends Content, TStructFieldContent {
623623 override string toString ( ) { result = s .toString ( ) + "." + field_ .toString ( ) }
624624}
625625
626+ /**
627+ * An element in an array.
628+ */
629+ final class ArrayElementContent extends Content , TArrayElement {
630+ ArrayElementContent ( ) { this = TArrayElement ( ) }
631+
632+ override string toString ( ) { result = "array[]" }
633+ }
634+
626635/**
627636 * Content stored at a position in a tuple.
628637 *
@@ -656,7 +665,7 @@ abstract class ContentSet extends TContentSet {
656665 abstract Content getAReadContent ( ) ;
657666}
658667
659- final private class SingletonContentSet extends ContentSet , TSingletonContentSet {
668+ final class SingletonContentSet extends ContentSet , TSingletonContentSet {
660669 private Content c ;
661670
662671 SingletonContentSet ( ) { this = TSingletonContentSet ( c ) }
@@ -879,6 +888,24 @@ module RustDataFlow implements InputSig<Location> {
879888 node2 .asExpr ( ) = access
880889 )
881890 or
891+ exists ( IndexExprCfgNode arr |
892+ c instanceof ArrayElementContent and
893+ node1 .asExpr ( ) = arr .getBase ( ) and
894+ node2 .asExpr ( ) = arr
895+ )
896+ or
897+ exists ( ForExprCfgNode for |
898+ c instanceof ArrayElementContent and
899+ node1 .asExpr ( ) = for .getIterable ( ) and
900+ node2 .asPat ( ) = for .getPat ( )
901+ )
902+ or
903+ exists ( SlicePatCfgNode pat |
904+ c instanceof ArrayElementContent and
905+ node1 .asPat ( ) = pat and
906+ node2 .asPat ( ) = pat .getAPat ( )
907+ )
908+ or
882909 exists ( TryExprCfgNode try |
883910 node1 .asExpr ( ) = try .getExpr ( ) and
884911 node2 .asExpr ( ) = try and
@@ -951,7 +978,21 @@ module RustDataFlow implements InputSig<Location> {
951978 node2 .asExpr ( ) = tuple
952979 )
953980 or
981+ c instanceof ArrayElementContent and
982+ node1 .asExpr ( ) =
983+ [
984+ node2 .asExpr ( ) .( ArrayRepeatExprCfgNode ) .getRepeatOperand ( ) ,
985+ node2 .asExpr ( ) .( ArrayListExprCfgNode ) .getAnExpr ( )
986+ ]
987+ or
954988 tupleAssignment ( node1 , node2 .( PostUpdateNode ) .getPreUpdateNode ( ) , c )
989+ or
990+ exists ( AssignmentExprCfgNode assignment , IndexExprCfgNode index |
991+ c instanceof ArrayElementContent and
992+ assignment .getLhs ( ) = index and
993+ node1 .asExpr ( ) = assignment .getRhs ( ) and
994+ node2 .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = index .getBase ( )
995+ )
955996 )
956997 or
957998 FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( Node:: FlowSummaryNode ) .getSummaryNode ( ) ,
@@ -1067,7 +1108,11 @@ private module Cached {
10671108 TPatNode ( PatCfgNode p ) or
10681109 TExprPostUpdateNode ( ExprCfgNode e ) {
10691110 isArgumentForCall ( e , _, _) or
1070- e = [ any ( FieldExprCfgNode access ) .getExpr ( ) , any ( TryExprCfgNode try ) .getExpr ( ) ]
1111+ e =
1112+ [
1113+ any ( IndexExprCfgNode i ) .getBase ( ) , any ( FieldExprCfgNode access ) .getExpr ( ) ,
1114+ any ( TryExprCfgNode try ) .getExpr ( )
1115+ ]
10711116 } or
10721117 TSsaNode ( SsaImpl:: DataFlowIntegration:: SsaNode node ) or
10731118 TFlowSummaryNode ( FlowSummaryImpl:: Private:: SummaryNode sn )
@@ -1152,6 +1197,7 @@ private module Cached {
11521197 TVariantFieldContent ( VariantCanonicalPath v , string field ) {
11531198 field = v .getVariant ( ) .getFieldList ( ) .( RecordFieldList ) .getAField ( ) .getName ( ) .getText ( )
11541199 } or
1200+ TArrayElement ( ) or
11551201 TTuplePositionContent ( int pos ) {
11561202 pos in [ 0 .. max ( [
11571203 any ( TuplePat pat ) .getNumberOfFields ( ) ,
0 commit comments