Skip to content

Commit 22261c1

Browse files
committed
Rust: Rename isIrrefutablePattern to isExhaustiveMatch
1 parent d0f978d commit 22261c1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,28 @@ class BooleanCompletion extends ConditionalCompletion, TBooleanCompletion {
123123
override string toString() { result = "boolean(" + value + ")" }
124124
}
125125

126-
/** Holds if `pat` is guaranteed to match. */
126+
/** Holds if `pat` is guaranteed to match at the point in the AST where it occurs. */
127127
pragma[nomagic]
128-
private predicate isIrrefutablePattern(Pat pat) {
128+
private predicate isExhaustiveMatch(Pat pat) {
129129
(
130130
pat instanceof WildcardPat
131131
or
132132
pat = any(IdentPat ip | not ip.hasPat() and ip = any(Variable v).getPat())
133133
or
134134
pat instanceof RestPat
135135
or
136-
// `let` statements without an `else` branch must be irrefutible
136+
// `let` statements without an `else` branch must be exhaustive
137137
pat = any(LetStmt let | not let.hasLetElse()).getPat()
138138
or
139-
// `match` expressions must be irrefutible, so last arm cannot fail
139+
// `match` expressions must be exhaustive, so last arm cannot fail
140140
pat = any(MatchExpr me).getLastArm().getPat()
141141
or
142-
// parameter patterns must be irrefutible
142+
// parameter patterns must be exhaustive
143143
pat = any(Param p).getPat()
144144
) and
145145
not pat = any(ForExpr for).getPat() // workaround until `for` loops are desugared
146146
or
147-
exists(Pat parent | isIrrefutablePattern(parent) |
147+
exists(Pat parent | isExhaustiveMatch(parent) |
148148
pat = parent.(BoxPat).getPat()
149149
or
150150
pat = parent.(IdentPat).getPat()
@@ -171,7 +171,7 @@ class MatchCompletion extends TMatchCompletion, ConditionalCompletion {
171171

172172
override predicate isValidForSpecific(AstNode e) {
173173
e instanceof Pat and
174-
if isIrrefutablePattern(e) then value = true else any()
174+
if isExhaustiveMatch(e) then value = true else any()
175175
}
176176

177177
override MatchSuccessor getAMatchingSuccessorType() { result.getValue() = value }

0 commit comments

Comments
 (0)