Skip to content

Rust: add MacroPat to isExhaustiveMatch #17746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Oct 12, 2024

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 12, 2024
@aibaars aibaars force-pushed the aibaars/macro-pat-irrefutable branch from 8a3c8fc to 493a68a Compare October 14, 2024 11:56
@aibaars aibaars changed the title Rust: add MacroPat to isIrrefutablePattern Rust: add MacroPat to isExhaustiveMatch Oct 14, 2024
@aibaars
Copy link
Contributor Author

aibaars commented Oct 14, 2024

@paldepind

@@ -149,6 +152,8 @@ private predicate isExhaustiveMatch(Pat pat) {
or
pat = parent.(IdentPat).getPat()
or
pat = parent.(MacroPat).getMacroCall().getExpanded()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary and L143 not enough?

If I understand correctly the cases here are about the exhaustiveness property flowing from patterns to their child constituents. This added line doesn't seem to really fit that pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 143 is for cases where a macro expands to a pattern that is known to be exhaustive (eg a wildcard) in that case the macro invocation is an exhaustive pattern.

Line 155 is for the case where a macro invocation appears in a position that should be exhaustive, such as the last arm in a match. In this case whatever the macro expands to is considered to be exhaustive as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, now I get it 😄

Co-authored-by: Simon Friis Vindum <simonfv@gmail.com>
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@aibaars aibaars merged commit 508e815 into main Oct 15, 2024
14 checks passed
@aibaars aibaars deleted the aibaars/macro-pat-irrefutable branch October 15, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants