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

Incosistency between else_if_without_else and needless_else #11662

Closed
c410-f3r opened this issue Oct 12, 2023 · 5 comments
Closed

Incosistency between else_if_without_else and needless_else #11662

c410-f3r opened this issue Oct 12, 2023 · 5 comments

Comments

@c410-f3r
Copy link
Contributor

c410-f3r commented Oct 12, 2023

else_if_without_else is allowed in restriction while needless_else warns in style although both deal with the same pattern. It is then probably a good move to put both in the same category.

@y21
Copy link
Member

y21 commented Oct 12, 2023

I personally disagree. They deal with the opposite pattern rather, and one is (in my experience) more idiomatic than the other.
Requiring an else on every single else if even when it's not needed sounds quite restrictive. An empty else OTOH seems much more sane to warn and is likely a mistake, possibly leftover from refactoring.

The same sort of argument can be made for implicit_return (restriction) and needless_return (style). Omitting return; as the last statement of a function is idiomatic Rust so it seems good to have needless_return be warn by default.

@Alexendoo
Copy link
Member

Yeah having both of these warn by default would create a cycle where we repeatedly ask the user to add an else {} then on the next run ask them to remove it

@c410-f3r
Copy link
Contributor Author

c410-f3r commented Oct 13, 2023

Looks like this is a desired undocumented behaviour, or is there any?

For those interested in consistency, semicolon_inside_block and semicolon_inside_block among possibly others are in the same category with the same level of restriction.

@Alexendoo
Copy link
Member

There are several pairs of lints that suggest opposites to each other, but the only case where they should be in the same category is if that category is restriction, meaning they're both considered individually opt in

@c410-f3r
Copy link
Contributor Author

@Alexendoo #11666

bors added a commit that referenced this issue Oct 16, 2023
Document conflicting lints

Documents the outcome described in #11662 so that the situation can be avoided in the future by other individuals.

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants