Skip to content

Fix the parsing logic of matches_pattern! to support _ at the top level in top-level structs. #627

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 6, 2025

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Apr 17, 2025

Fix the parsing logic of matches_pattern! to support _ at the top level in top-level structs.

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

We add pattern_only() matcher for the case when field_matcher is empty and skip the is() wrapping.

Toward #626

Copy link

google-cla bot commented Apr 17, 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.

@copybara-service copybara-service bot changed the title Fix the parsing of matches_pattern! to properly support enums like Option. Previously, the pattern Some(_) would be parsed as None. Now the Some variant with wildcard will be parsed correctly. Fix the parsing logic of matches_pattern! to support _ at the top level in top-level structs. Apr 22, 2025
@copybara-service copybara-service bot force-pushed the test_748656817 branch 6 times, most recently from dcb345e to fd44fb2 Compare May 6, 2025 09:40
… level in top-level structs.

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

We add `pattern_only()` matcher for the case when field_matcher is empty and skip the `is()` wrapping.

Toward #626

PiperOrigin-RevId: 755284260
@copybara-service copybara-service bot merged commit 3a977ca into main May 6, 2025
@copybara-service copybara-service bot deleted the test_748656817 branch May 6, 2025 09:44
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