Skip to content

Commit

Permalink
Merge pull request #17746 from github/aibaars/macro-pat-irrefutable
Browse files Browse the repository at this point in the history
Rust: add MacroPat to isExhaustiveMatch
  • Loading branch information
aibaars authored Oct 15, 2024
2 parents cc1e33f + ae7afa7 commit 508e815
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ private predicate isExhaustiveMatch(Pat pat) {
// `match` expressions must be exhaustive, so last arm cannot fail
pat = any(MatchExpr me).getLastArm().getPat()
or
// macro invocations are exhaustive if their expansion is
pat = any(MacroPat mp | isExhaustiveMatch(mp.getMacroCall().getExpanded()))
or
// parameter patterns must be exhaustive
pat = any(Param p).getPat()
) and
Expand All @@ -149,6 +152,8 @@ private predicate isExhaustiveMatch(Pat pat) {
or
pat = parent.(IdentPat).getPat()
or
pat = parent.(MacroPat).getMacroCall().getExpanded()
or
pat = parent.(ParenPat).getPat()
or
pat = parent.(RecordPat).getRecordPatFieldList().getField(_).getPat()
Expand Down

0 comments on commit 508e815

Please sign in to comment.