Skip to content

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ macro_rules! declare_clippy_lint {
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
}
};
{ $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {

{ $(#[$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 } => {
Comment on lines +130 to +133
Copy link
Member Author

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)

declare_tool_lint! {
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
$(#[$attr])* pub clippy::$name, $level, $description, report_in_external_macro: true
}
};

{ $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
declare_tool_lint! {
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
Expand Down
6 changes: 4 additions & 2 deletions clippy_lints/src/panic_unimplemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ declare_clippy_lint! {
/// ```
pub UNIMPLEMENTED,
restriction,
"`unimplemented!` should not be present in production code"
"`unimplemented!` should not be present in production code",
level = Warn
}

declare_clippy_lint! {
Expand All @@ -51,7 +52,8 @@ declare_clippy_lint! {
/// ```
pub TODO,
restriction,
"`todo!` should not be present in production code"
"`todo!` should not be present in production code",
level = Warn
}

declare_clippy_lint! {
Expand Down