-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: unused_unit #3233
new lint: unused_unit #3233
Conversation
Maybe the ignored |
Maybe the lint level selection was broken when tools lints were added? |
I thought the same, so I searched for merge commits by @bors that broke the lint level definition and I got it down to 3 commits: #3198 (comment). None of these commits are related to |
I have extended the lint to cover explicit unit return types in |
2c413d8
to
82686a8
Compare
I had missed adding the lint to the lint-array, which resulted in the failing allow annotation. This should hopefully now work. r? once CI is happy. |
4568461
to
f9732ef
Compare
@oli-obk r? |
clippy_lints/src/returns.rs
Outdated
@@ -68,6 +68,25 @@ declare_clippy_lint! { | |||
the end of a block" | |||
} | |||
|
|||
/// **What it does:** Checks for unit (`()`) expressions that can be removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe too pedantic but there is no dot at the end of the line.
@llogiq This seems to act weird in cases like this: thread_local!(static A: () = ()); yields
... and |
True, that looks weird. Then again, why do you need a zero-sized thread-local? |
You'd be surprised :) For identifying threads when implementing a reentrant mutex. |
This is the rejected unused_parens extension plus a lint for units in function return types and return expressions.
It appears to fail to obey the
allow(..)
attributes though (seecopies.rs
) – does anyone know why that happens?