@@ -12,7 +12,6 @@ private import codeql.rust.elements.Call
1212private import SsaImpl as SsaImpl
1313private import codeql.rust.controlflow.internal.Scope as Scope
1414private import codeql.rust.internal.PathResolution
15- private import codeql.rust.internal.TypeInference as TypeInference
1615private import codeql.rust.controlflow.ControlFlowGraph
1716private import codeql.rust.dataflow.Ssa
1817private import codeql.rust.dataflow.FlowSummary
@@ -157,7 +156,7 @@ final class ArgumentPosition extends TArgumentPosition {
157156 inMethodCall = true
158157 or
159158 result = call .( IndexExpr ) .getIndex ( ) and
160- pos = 1 and
159+ pos = 0 and
161160 inMethodCall = true
162161 )
163162 }
@@ -201,8 +200,7 @@ final class ArgumentPosition extends TArgumentPosition {
201200predicate isArgumentForCall ( Expr arg , Call call , ArgumentPosition pos ) {
202201 // TODO: Handle index expressions as calls in data flow.
203202 not call instanceof IndexExpr and
204- arg = pos .getArgument ( call ) and
205- not ( pos .isReceiver ( ) and call .receiverImplicitlyBorrowed ( ) )
203+ arg = pos .getArgument ( call )
206204}
207205
208206/** Provides logic related to SSA. */
@@ -333,14 +331,6 @@ module LocalFlow {
333331 or
334332 nodeFrom .asPat ( ) .( OrPat ) .getAPat ( ) = nodeTo .asPat ( )
335333 or
336- // Simple value step from receiver expression to receiver node, in case
337- // there is no implicit deref or borrow operation.
338- nodeFrom .asExpr ( ) = nodeTo .( ReceiverNode ) .getReceiver ( )
339- or
340- // The dual step of the above, for the post-update nodes.
341- nodeFrom .( PostUpdateNode ) .getPreUpdateNode ( ) .( ReceiverNode ) .getReceiver ( ) =
342- nodeTo .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( )
343- or
344334 nodeTo .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) =
345335 getPostUpdateReverseStep ( nodeFrom .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) , true )
346336 }
@@ -430,7 +420,7 @@ module RustDataFlow implements InputSig<Location> {
430420 node .( FlowSummaryNode ) .getSummaryNode ( ) .isHidden ( ) or
431421 node instanceof CaptureNode or
432422 node instanceof ClosureParameterNode or
433- node instanceof ReceiverNode or
423+ node instanceof DerefBorrowNode or
434424 node .asExpr ( ) instanceof ParenExpr or
435425 nodeIsHidden ( node .( PostUpdateNode ) .getPreUpdateNode ( ) )
436426 }
@@ -584,16 +574,16 @@ module RustDataFlow implements InputSig<Location> {
584574 }
585575
586576 pragma [ nomagic]
587- private predicate implicitDerefToReceiver ( Node node1 , ReceiverNode node2 , ReferenceContent c ) {
588- TypeInference :: receiverHasImplicitDeref ( node1 . asExpr ( ) ) and
589- node1 .asExpr ( ) = node2 .getReceiver ( ) and
577+ private predicate implicitDeref ( Node node1 , DerefBorrowNode node2 , ReferenceContent c ) {
578+ not node2 . isBorrow ( ) and
579+ node1 .asExpr ( ) = node2 .getNode ( ) and
590580 exists ( c )
591581 }
592582
593583 pragma [ nomagic]
594- private predicate implicitBorrowToReceiver ( Node node1 , ReceiverNode node2 , ReferenceContent c ) {
595- TypeInference :: receiverHasImplicitBorrow ( node1 . asExpr ( ) ) and
596- node1 .asExpr ( ) = node2 .getReceiver ( ) and
584+ private predicate implicitBorrow ( Node node1 , DerefBorrowNode node2 , ReferenceContent c ) {
585+ node2 . isBorrow ( ) and
586+ node1 .asExpr ( ) = node2 .getNode ( ) and
597587 exists ( c )
598588 }
599589
@@ -626,10 +616,15 @@ module RustDataFlow implements InputSig<Location> {
626616 c instanceof ReferenceContent and
627617 node1 .asPat ( ) .( RefPat ) .getPat ( ) = node2 .asPat ( )
628618 or
629- exists ( FieldExpr access |
630- node1 .asExpr ( ) = access .getContainer ( ) and
619+ exists ( FieldExpr access , Expr container |
631620 node2 .asExpr ( ) = access and
632- access = c .( FieldContent ) .getAnAccess ( )
621+ access = c .( FieldContent ) .getAnAccess ( ) and
622+ container = access .getContainer ( )
623+ |
624+ not any ( DerefBorrowNode n ) .getNode ( ) = container and
625+ node1 .asExpr ( ) = container
626+ or
627+ node1 .( DerefBorrowNode ) .getNode ( ) = container
633628 )
634629 or
635630 exists ( IndexExpr arr |
@@ -680,12 +675,10 @@ module RustDataFlow implements InputSig<Location> {
680675 referenceExprToExpr ( node2 .( PostUpdateNode ) .getPreUpdateNode ( ) ,
681676 node1 .( PostUpdateNode ) .getPreUpdateNode ( ) , c )
682677 or
683- // Step from receiver expression to receiver node, in case of an implicit
684- // dereference.
685- implicitDerefToReceiver ( node1 , node2 , c )
678+ implicitDeref ( node1 , node2 , c )
686679 or
687680 // A read step dual to the store step for implicit borrows.
688- implicitBorrowToReceiver ( node2 .( PostUpdateNode ) .getPreUpdateNode ( ) ,
681+ implicitBorrow ( node2 .( PostUpdateNode ) .getPreUpdateNode ( ) ,
689682 node1 .( PostUpdateNode ) .getPreUpdateNode ( ) , c )
690683 or
691684 VariableCapture:: readStep ( node1 , c , node2 )
@@ -793,9 +786,7 @@ module RustDataFlow implements InputSig<Location> {
793786 or
794787 VariableCapture:: storeStep ( node1 , c , node2 )
795788 or
796- // Step from receiver expression to receiver node, in case of an implicit
797- // borrow.
798- implicitBorrowToReceiver ( node1 , node2 , c )
789+ implicitBorrow ( node1 , node2 , c )
799790 }
800791
801792 /**
0 commit comments