Skip to content

Fix the parsing logic of matches_pattern! to support _ at the top level in braced enums. #634

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 1 commit into from
May 12, 2025

Conversation

copybara-service[bot]
Copy link

Fix the parsing logic of matches_pattern! to support _ at the top level in braced enums.

In the current parsing logic, the _ field in pattern AsEnum::Foo { a_field : _ } is parsed as None, and as a result no FieldMatcher is generated, and the internal is() matcher only evaluates the innerMatcher(the field_matcher).

With the current change, when no field_matcher is present, the matches pattern macro verifies the variant of the Enum with pattern_only() matcher.

Toward #626

Copy link

google-cla bot commented May 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

…evel in braced enums.

In the current parsing logic, the `_` field in pattern `AsEnum::Foo { a_field : _ }` is parsed as None, and as a result no FieldMatcher is generated, and the internal `is()` matcher only evaluates the innerMatcher(the field_matcher).

With the current change, when no field_matcher is present, the matches pattern macro verifies the variant of the Enum with `pattern_only()` matcher.

Toward #626

PiperOrigin-RevId: 757644200
@copybara-service copybara-service bot merged commit 1d64715 into main May 12, 2025
@copybara-service copybara-service bot deleted the test_755381147 branch May 12, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants