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: pub enum tuple variant adds or removes field (i.e. tuple arity changed) #554

Closed
Tracked by #5
obi1kenobi opened this issue Oct 12, 2023 · 5 comments
Closed
Tracked by #5
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 Oct 12, 2023

pub enum Example {
    Variant(a: i64, /* b: i64 */),
}

Both adding and removing the commented-out portion is a breaking change, and I don't believe we currently would catch that.

@obi1kenobi obi1kenobi changed the title pub enum tuple variant adds or removes field (i.e. tuple arity changed) New lint: pub enum tuple variant adds or removes field (i.e. tuple arity changed) Oct 12, 2023
@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 Oct 12, 2023
@me-diru
Copy link
Contributor

me-diru commented Mar 28, 2024

Hey!

I was checking out this issue. The adds and removes field cases in a pub enum are already checked with separate lints

Do they both cover the case of tuple arity being changed, or are we looking for something different here? thanks

@obi1kenobi
Copy link
Owner Author

I think those lints only cover changes enums' struct variants, not changes in tuple variants. More info on different enum variant kinds: https://doc.rust-lang.org/std/keyword.enum.html

For tuple variants, we can probably have just a single lint that checks that "the tuple contains a different number of elements."

As a query, this can make use of the @fold @transform(op: "count") combination of directives to count how many fields each tuple has, and then use @tag, @filter, and @output accordingly to output the old and new counts and establish they are different. I believe one can find examples of that combination of directives in other lints' queries already.

@me-diru
Copy link
Contributor

me-diru commented Mar 30, 2024

Thanks for the quick response!

I have written a lint query for the same. However, the enum tuple variant field changes are already covered in the following lints.

Please let me know if I am misinterpreting it; it was interesting to understand how the querying works, though; writing a lint itself is pretty intuitive

@obi1kenobi
Copy link
Owner Author

Ah darn, I did a pass through the lints to see if those were implemented, and yet somehow I missed them anyway. Sorry about my sloppiness that ended up wasting your time here.

You're right, this issue is completed with no further action needed. If you'd like, I can find and suggest other opportunities to write lints or otherwise contribute to the project — it would be much appreciated!

@obi1kenobi
Copy link
Owner Author

Some relatively easy high-impact lints here, for example: #633

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

No branches or pull requests

2 participants