Rust: Address review comments

This commit is contained in:
Simon Friis Vindum
2025-02-17 13:35:46 +01:00
parent 8b3c1ab698
commit dcfe65bc66
2 changed files with 11 additions and 7 deletions

View File

@@ -648,11 +648,11 @@ module PatternTrees {
abstract class PostOrderPatTree extends StandardPatTree, StandardPostOrderTree { }
class IdentPatTree extends StandardPostOrderTree, IdentPat {
override AstNode getChildNode(int i) {
i = 0 and result = this.getPat()
class IdentPatTree extends PostOrderTree, IdentPat {
override predicate first(AstNode node) {
first(this.getPat(), node)
or
i = 1 and result = this.getName()
not this.hasPat() and node = this.getName()
}
override predicate last(AstNode node, Completion c) {
@@ -663,11 +663,15 @@ module PatternTrees {
override predicate succ(AstNode pred, AstNode succ, Completion c) {
// Edge from successful subpattern to name
super.succ(pred, succ, c) and c.(MatchCompletion).succeeded()
last(this.getPat(), pred, c) and
first(this.getName(), succ) and
c.(MatchCompletion).succeeded()
or
// Edge from name to the identifier pattern itself
last(this.getName(), pred, c) and succ = this and completionIsNormal(c)
}
override predicate propagatesAbnormal(AstNode child) { child = this.getPat() }
}
class BoxPatTree extends PreOrderPatTree, BoxPat {

View File

@@ -62,8 +62,8 @@ module Impl {
}
/**
* Holds if `p` declares a variable named `name` at `definingNode`. Normally,
* `definingNode = p`, except in cases like
* Holds if `name` declares a variable named `text` at `definingNode`.
* Normally, `definingNode = name`, except in cases like
*
* ```rust
* match either {