Skip to content

New lint: empty_enum_variants_with_brackets - #12033

Closed
NullSpaceBoy wants to merge 2 commits into
rust-lang:masterfrom
NullSpaceBoy:12007-detect-empty-enums-with-brackets
Closed

New lint: empty_enum_variants_with_brackets#12033
NullSpaceBoy wants to merge 2 commits into
rust-lang:masterfrom
NullSpaceBoy:12007-detect-empty-enums-with-brackets

Conversation

@NullSpaceBoy

Copy link
Copy Markdown
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

rustbot commented Dec 28, 2023

Copy link
Copy Markdown
Collaborator

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

J-ZhengLi commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

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

@NullSpaceBoy

Copy link
Copy Markdown
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

rustbot commented Dec 29, 2023

Copy link
Copy Markdown
Collaborator

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:

@NullSpaceBoy

Copy link
Copy Markdown
Contributor Author

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

@NullSpaceBoy
NullSpaceBoy deleted the 12007-detect-empty-enums-with-brackets branch December 29, 2023 11:05
@bors

bors commented Dec 29, 2023

Copy link
Copy Markdown
Contributor

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

@llogiq

llogiq commented Dec 31, 2023

Copy link
Copy Markdown
Contributor

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

@NullSpaceBoy

Copy link
Copy Markdown
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