-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Make clippy::todo
and clippy::unimplemented
warn by default.
#7494
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
Conversation
Unlike panic, it's almost never correct to have this in a production context. Make them warn by default to avoid bugs slipping through.
r? @Manishearth (rust-highfive has picked a reviewer for you, use r? to override) |
{ $(#[$attr:meta])* pub $name:ident, restriction, $description:tt } => { | ||
declare_clippy_lint! { $(#[$attr])* pub $name, restriction, $description, level = Allow } | ||
}; | ||
{ $(#[$attr:meta])* pub $name:ident, restriction, $description:tt, level = $level:ident } => { |
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.
This changed from tt
to ident
because it made the error message way easier to read. Before it was
error: no rules expected the token `LET_UNDERSCORE_MUST_USE`
--> clippy_lints/src/let_underscore.rs:30:9
|
30 | pub LET_UNDERSCORE_MUST_USE,
| ^^^^^^^^^^^^^^^^^^^^^^^ no rules expected this token in macro call
|
::: clippy_lints/src/lib.rs:98:1
|
98 | macro_rules! declare_clippy_lint {
| -------------------------------- when calling this macro
now it's
error: no rules expected the token `LET_UNDERSCORE_MUST_USE`
--> clippy_lints/src/lib.rs:131:45
|
98 | macro_rules! declare_clippy_lint {
| -------------------------------- when calling this macro
...
131 | declare_clippy_lint! { $(#[$attr])* $name, restriction, $description, level = Allow }
| ^^^^^ no rules expected this token in macro call
|
::: clippy_lints/src/let_underscore.rs:11:1
|
11 | / declare_clippy_lint! {
12 | | /// **What it does:** Checks for `let _ = <expr>`
13 | | /// where expr is #[must_use]
14 | | ///
... |
32 | | "non-binding let on a `#[must_use]` expression"
33 | | }
| |_- in this macro invocation
|
= note: this error originates in the macro `declare_clippy_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
(the original issue was I forgot pub
in front of clippy::$name
below)
The tests are failing because a bunch of lint tests are using |
I don't think we should do this. In our Also in the Clippy 1.0 RFC we definied the restriction group as:
If those two macros are "almost never correct to have this in a production context", those lints should therefore not be in the Also @rust-lang/clippy should we move those lints to a warn-by-default group? I don't have a strong opinion here (about allow- vs warn-by-default). |
Gotcha. I can move them to |
Correctness is deny-by-default. I'm not sure where the best place for those lints is, so I'd like input from others first. |
|
I don't think this should be warn by default, definitely not deny-by-default.
This is a narrow understanding of the users of clippy; in fact the codebases I have worked on professionally in the past have always tolerated todo/unimplemented in certain regions of code. Just because you're running clippy on it doesn't mean it is production ready, it can be in an experimental component or something else. |
Hmm, your use case makes sense, but it seems strange to me that "todo is ok" is the default. You could always |
This is a harder line to draw than with other restriction lints. I think the applicability of these lints is too dependent on project state/goals/preferences to be warn-by-default. Perhaps |
Yeah I think it makes sense as either restriction or pedantic. But it varies from project to project.
To me this is one of those cases where clippy can't supplant code review; todo/unimplemented are pretty obvious in code review already; and it highly depends on the context. As I said earlier, Clippy's audience is not just people verifying "production code"; it's a far broader one. It's relatively common to check unimplemented/todos in when you're working on a large not-yet-production-ready feature. |
I think it would make sense to enable this lint shortly before a release to inspect each of these reports. Having them as warn-by-default would be too strong IMO. This case reminds me of the
This is basically the second instance where we say: "You might want to look at these reports shortly before the release, but they are not bad per se". Currently, we basically expect the user to know these cases. What would you all think about adding a collection of check we suggest before releasing? This could be a simple section in the |
We had a suggestion to move all the 'production' lints into their own group - #5755 . It might be a good idea to make a new group and apply the new level to the group as a whole. |
This could be a possibility. However, I wouldn't add it as a new standalone lint-group, but instead as an additional collection like @rustbot label +S-needs-discussion |
I don't really want lints to be in multiple groups, if the one group is not a strict subset of another group. I'd be fine to add a new allow-by-default group called |
The production category doesn't quite carry its weight IMO. The
I like this idea, if we say something like "depending on the project, some of these lints might be useful to enable at the crate level". |
I'm also in favor of adding documentation instead of adding a new lint group. 👍 |
Unlike panic, it's almost never correct to have this in a production context.
Make them warn by default to avoid bugs slipping through.
It looks like this is the first time a lint level hasn't been solely determined by the group it's in, but I think it's correct: denying
todo!
is both a restriction, and should be a loud warning.This would have caught a bug I introduced in my own codebase last week: cloudflare/wrangler-legacy#2012
changelog: Make [
clippy::todo
] and [clippy::unimplemented
] warn by default.