Skip to content

Commit fce853d

Browse files
committed
wip
1 parent d5a92ce commit fce853d

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ private module Input implements InputSig1, InputSig2 {
579579

580580
predicate isExhaustive(Ast::Switch switch) { any() }
581581

582-
predicate patternCannotFail(Ast::Pattern pattern) { cannotCauseMatchFailure(pattern) }
582+
predicate patternIsTest(Ast::Pattern pattern) { not cannotCauseMatchFailure(pattern) }
583583

584584
predicate patternAlwaysMatches(Ast::Pattern pattern) { guaranteedMatchPosition(pattern) }
585585

‎shared/controlflow/codeql/controlflow/ControlFlowGraph.qll‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
582582
* This does not imply that the overall pattern always matches, since a nested pattern
583583
* may still fail.
584584
*/
585-
default predicate patternCannotFail(Pattern pattern) { none() }
585+
default predicate patternIsTest(Pattern pattern) { none() }
586586

587587
/** Holds if `pattern` and all its nested patterns are guaranteed to match. */
588588
default predicate patternAlwaysMatches(Pattern pattern) { none() }
@@ -1035,10 +1035,9 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
10351035
)
10361036
}
10371037

1038-
private predicate patternCannotFail(Pattern pattern) {
1039-
patternAlwaysMatches(pattern) or Input1::patternCannotFail(pattern)
1040-
}
1041-
1038+
// private predicate patternCannotFail(Pattern pattern) {
1039+
// patternAlwaysMatches(pattern) or Input1::patternCannotFail(pattern)
1040+
// }
10421041
private predicate constantCondition(AstNode n, ConditionalSuccessor t) {
10431042
patternAlwaysMatches(n) and
10441043
t.(MatchingSuccessor).getValue() = true
@@ -1616,7 +1615,7 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16161615
(
16171616
n2.isAdditional(pattern, outerPatternMatchTag())
16181617
or
1619-
not patternCannotFail(pattern) and
1618+
Input1::patternIsTest(pattern) and
16201619
isAfterMatch(n2, pattern, false)
16211620
)
16221621
or
@@ -1672,7 +1671,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16721671
n1.isIn(pattern) and isAfterMatch(n2, pattern, true)
16731672
or
16741673
n1.isIn(pattern) and
1675-
not patternCannotFail(pattern) and
1674+
Input1::patternIsTest(pattern) and
1675+
// not patternAlwaysMatches(pattern) and
16761676
isAfterMatch(n2, pattern, false)
16771677
}
16781678

@@ -1689,7 +1689,6 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16891689
n2.isBefore(getRankedPattern(pattern, i + 1))
16901690
or
16911691
not exists(getRankedPattern(pattern, i + 1)) and
1692-
not patternCannotFail(pattern) and
16931692
isAfterMatch(n2, pattern, false)
16941693
)
16951694
)

0 commit comments

Comments
 (0)