rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.5k stars 1.55k forks source link

unused or incorrect lints in Cargo.toml fail silently #12124

Open clayrab opened 10 months ago

clayrab commented 10 months ago

Summary

Adding this section to Cargo.toml produces no errors or warnings:

[lints.clippy]
asdf = "deny"

I'm trying to do this:

[lints.clippy]
blocks_in_conditions = "allow"

I believe this isn't supported, but can't be sure becuase it produces no errors.

The same setting in clippy.toml blows up, which is what I'd expect to see if it's done via Cargo.toml as well:

  --- stderr
  error: error reading Clippy's configuration file: unknown field `blocks_in_conditions`, expected one of
             absolute-paths-allowed-crates             avoid-breaking-exported-api              future-size-threshold                       standard-macro-braces
             absolute-paths-max-segments               await-holding-invalid-types              ignore-interior-mutability                  struct-field-name-threshold
             accept-comment-above-attributes           blacklisted-names                        large-error-threshold                       suppress-restriction-lint-in-const
             accept-comment-above-statement            cargo-ignore-publish                     literal-representation-threshold            third-party
             allow-dbg-in-tests                        check-private-items                      matches-for-let-else                        too-large-for-stack
             allow-expect-in-tests                     cognitive-complexity-threshold           max-fn-params-bools                         too-many-arguments-threshold
             allow-mixed-uninlined-format-args         cyclomatic-complexity-threshold          max-include-file-size                       too-many-lines-threshold
             allow-one-hash-in-raw-strings             disallowed-macros                        max-struct-bools                            trivial-copy-size-limit
             allow-print-in-tests                      disallowed-methods                       max-suggested-slice-pattern-length          type-complexity-threshold
             allow-private-module-inception            disallowed-names                         max-trait-bounds                            unnecessary-box-size
             allow-unwrap-in-tests                     disallowed-types                         min-ident-chars-threshold                   unreadable-literal-lint-fractions
             allowed-dotfiles                          doc-valid-idents                         missing-docs-in-crate-items                 upper-case-acronyms-aggressive
             allowed-idents-below-min-chars            enable-raw-pointer-heuristic-for-send    msrv                                        vec-box-size-threshold
             allowed-scripts                           enforce-iter-loop-reborrow               pass-by-value-size-limit                    verbose-bit-mask-threshold
             arithmetic-side-effects-allowed           enforced-import-renames                  semicolon-inside-block-ignore-singleline    warn-on-all-wildcard-imports
             arithmetic-side-effects-allowed-binary    enum-variant-name-threshold              semicolon-outside-block-ignore-multiline    
             arithmetic-side-effects-allowed-unary     enum-variant-size-threshold              single-char-binding-names-threshold         
             array-size-threshold                      excessive-nesting-threshold              stack-size-threshold                        
   --> /Users/clay/projects/evm/clippy.toml:3:1 

Reproducer

I tried this code:

<code>

I expected to see this happen:

Instead, this happened:

Version

No response

Additional Labels

No response

y21 commented 10 months ago

Adding this section to Cargo.toml produces no errors or warnings:

For me it produces this warning:

warning[E0602]: unknown lint: `clippy::asdf`
  |
  = help: did you mean: `clippy::all`
  = note: requested on the command line with `-D clippy::asdf`
  = note: `#[warn(unknown_lints)]` on by default

Though only if invoked with clippy. With just cargo check it doesn't, because that directly invokes rustc and clippy doesn't get a chance to register its lints. And I presume it avoids linting if a tool doesn't register any lints because then you'd get an unknown lint warning even for existing lints if run with cargo check.

I'm trying to do this:

That looks like it should work

mulkieran commented 2 months ago

It works correctly for me on current stable version of clippy.

Suggest closing.

error[E0602]: unknown lint: `clippy::asdf`
  |
  = help: did you mean: `clippy::all`
  = note: requested on the command line with `-D clippy::asdf`
  = note: `-D unknown-lints` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(unknown_lints)]`