-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New lint: Have a semicolon on the last block statement if it returns nothing #6467
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
Comments
I believe that this could be a good first issue. I'm not sure in which file it would be implemented by you could roughly do the following to implement this lint:
@rustbot label +good first issue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@rustbot label +good-first-issue |
Regarding the lint level: This should probably be pedantic, since it doesn't really matter. Great explanation how to implement this @xFrednet! |
I can't get an example for this lint to compile. Am I missing something? (playground) |
You're right @camsteffen the expression has to return the unit type |
Cool. I guess the difference is that |
Two questions.
|
|
Ah nevermind. I thought this might not require type checking. |
I've started to implement this on my own fork but ran into an issue while testing. I first tested the lint on the |
Is the lint firing on the block that is part of the macro expansion? macro_rules! assert_eq {
($left:expr, $right:expr) => ({ // <- don't lint on the block that starts here You could do |
Actually yes, it's exactly that line. |
If you need more help, head over to zulip. |
What it does
Validates that the last block statement ends with a semicolon if it returns nothing.
Categories (optional)
clippy::style
Advantages
It leads to consistent block formatting.
Extending the block with new code doesn't require a change in previous last line
Example:
It makes block linting easier for us
Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: