Skip to content
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

New lint: public API struct became enum or union #954

Closed
1 of 2 tasks
Tracked by #5
obi1kenobi opened this issue Sep 27, 2024 · 0 comments · Fixed by #963
Closed
1 of 2 tasks
Tracked by #5

New lint: public API struct became enum or union #954

obi1kenobi opened this issue Sep 27, 2024 · 0 comments · Fixed by #963
Labels
A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.

Comments

@obi1kenobi
Copy link
Owner

obi1kenobi commented Sep 27, 2024

Inspired by this post: https://internals.rust-lang.org/t/rest-patterns-foo-should-match-non-struct-types/21607

TL;DR: Given a type Example, the pattern in matches!(value, Example { .. }) is only valid if Example is a struct. It fails on both enums and unions at the moment: playground

We already have a similar lint for changing a public API struct with public fields into an enum or union: struct_with_pub_fields_changed_type. The breakage there is more compelling than "empty pattern match" so we should keep that lint. We should make the new lints disjoint from it, so that users see one or the other but never both.

We also have a lint for constructible structs changing to another type: constructible_struct_changed_type. The breakage there is also more compelling than "empty pattern match" so we should keep that lint too. The new lints should be disjoint from it as well.

The new lints here should therefore be:

The new lints will be quite similar to the related lints mentioned above. Make sure to check out our contributing guide, and take a look at what prior lints' merged PRs looked like so you know what to expect. It's easier than you think!

Thanks to @jhpratt for bringing this to my attention!

@obi1kenobi obi1kenobi added A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue. labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant