Skip to content

Commit dcfe65b

Browse files
committed
Rust: Address review comments
1 parent 8b3c1ab commit dcfe65b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ module PatternTrees {
648648

649649
abstract class PostOrderPatTree extends StandardPatTree, StandardPostOrderTree { }
650650

651-
class IdentPatTree extends StandardPostOrderTree, IdentPat {
652-
override AstNode getChildNode(int i) {
653-
i = 0 and result = this.getPat()
651+
class IdentPatTree extends PostOrderTree, IdentPat {
652+
override predicate first(AstNode node) {
653+
first(this.getPat(), node)
654654
or
655-
i = 1 and result = this.getName()
655+
not this.hasPat() and node = this.getName()
656656
}
657657

658658
override predicate last(AstNode node, Completion c) {
@@ -663,11 +663,15 @@ module PatternTrees {
663663

664664
override predicate succ(AstNode pred, AstNode succ, Completion c) {
665665
// Edge from successful subpattern to name
666-
super.succ(pred, succ, c) and c.(MatchCompletion).succeeded()
666+
last(this.getPat(), pred, c) and
667+
first(this.getName(), succ) and
668+
c.(MatchCompletion).succeeded()
667669
or
668670
// Edge from name to the identifier pattern itself
669671
last(this.getName(), pred, c) and succ = this and completionIsNormal(c)
670672
}
673+
674+
override predicate propagatesAbnormal(AstNode child) { child = this.getPat() }
671675
}
672676

673677
class BoxPatTree extends PreOrderPatTree, BoxPat {

rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ module Impl {
6262
}
6363

6464
/**
65-
* Holds if `p` declares a variable named `name` at `definingNode`. Normally,
66-
* `definingNode = p`, except in cases like
65+
* Holds if `name` declares a variable named `text` at `definingNode`.
66+
* Normally, `definingNode = name`, except in cases like
6767
*
6868
* ```rust
6969
* match either {

0 commit comments

Comments
 (0)