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

Encourage removing { .. } from a pattern if enum variant is field-less #13400

Open
urben1680 opened this issue Sep 15, 2024 · 1 comment
Open
Labels
A-lint Area: New lints

Comments

@urben1680
Copy link

urben1680 commented Sep 15, 2024

What it does

Match patterns using Enum::Variant { .. } should be linted on if the enum variant is field-less.

Example:

match Some(42) {
    Some(v) => v,
    None { .. } /* <- lint this */ => 1
}

Advantage

  • Removes noise from when the vairant used to have fields (before refactoring for example)

Drawbacks

  • This pattern may still useful in macros so this should still be possible to be ignored with an [allow(...)]

Example

None { .. } => 1
     ^^^^^^

Could be written as:

None => 1
@urben1680 urben1680 added the A-lint Area: New lints label Sep 15, 2024
@urben1680 urben1680 changed the title Encourage removing { .. } of a pattern if enum variant is field-less Encourage removing { .. } from a pattern if enum variant is field-less Sep 16, 2024
@lolbinarycat
Copy link

This pattern may still useful in macros so this should still be possible to be ignored with an [allow(...)]

  1. all lints can be ignored in that way, if they couldn't be, they wouldn't be lints, they would be errors
  2. macro generated code is usually not linted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants