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: empty_enum_variants_with_brackets #12033

Conversation

ARandomDev99
Copy link
Contributor

This lint checks for enum variants that don't have any fields but are declared using brackets.

Closes #12007

changelog: new lint: [empty_enum_variants_with_brackets]

This lint checks for enum variants that don't have any fields but are declared using brackets.
@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 28, 2023
@J-ZhengLi
Copy link
Member

J-ZhengLi commented Dec 29, 2023

Hello~ 😄

Since this code logic shares a lot common with [empty_struct_with_brackets], for example those functions are exactly the same, I think you can merge these two files together, but keep them as separated lints.

That means have the declare_lint_pass! change to something like... :

declare_lint_pass!(EmptyWithBrackets => [
    EMPTY_ENUM_VARIANTS_WITH_BRACKETS,
    EMPTY_STRUCTS_WITH_BRACKETS,
]);

and in that EarlyLintPass impl, move your lint logic there:

impl EarlyLintPass for EmptyWithBrackes {
    /// code for empty_structs_with_brackets... bla bla
    fn check_item()

   /// your logic...
    fn check_variant()
}

reduces repeating code

@ARandomDev99
Copy link
Contributor Author

That makes sense. I shall make these changes.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Dec 29, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2023

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git rebase -i master
$ # delete any merge commits in the editor that appears
$ git push --force-with-lease

The following commits are merge commits:

@ARandomDev99
Copy link
Contributor Author

I'll be opening another PR after making the suggested changes.

@ARandomDev99 ARandomDev99 deleted the 12007-detect-empty-enums-with-brackets branch December 29, 2023 11:05
@bors
Copy link
Contributor

bors commented Dec 29, 2023

☔ The latest upstream changes (presumably #10283) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq
Copy link
Contributor

llogiq commented Dec 31, 2023

Feel free to add r? @llogiq to the description so I get to review it, as I already have the relevant context.

@ARandomDev99
Copy link
Contributor Author

@llogiq another PR I've opened regarding this issue has already been merged. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect Enum Objects with empty attribute body using {}
5 participants