mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Merge pull request #17746 from github/aibaars/macro-pat-irrefutable
Rust: add MacroPat to isExhaustiveMatch
This commit is contained in:
@@ -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
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user