Skip to content

many_single_char_names incorrectly triggered if 'single-char-binding-names-threshold = 0' #4086

Closed
@BafDyce

Description

@BafDyce

As I don't want to allow ANY variable names with only one character, I have the following clippy.toml:

single-char-binding-names-threshold = 0

Additionally, I run clippy with -- -D warnings to force myself to write clean & idiomatic code.

However, now clippy (and therefore all my CI jobs) fail with the following error:

$ cargo clippy -- -D warnings
    Checking clippy-issue-single-char-names v0.1.0 (/path/to/clippy-issue-single-char-names)
error: 0 bindings with single-character names in scope
  |
  = note: `-D clippy::many-single-char-names` implied by `-D warnings`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names

error: aborting due to previous error

error: Could not compile `clippy-issue-single-char-names`.

This can also be reproduced by a simple hello-world example, as generated by running cargo new, as demonstrated here:

$ cargo new --bin clippy-issue-single-char-names
     Created binary (application) `clippy-issue-single-char-names` package
$ cd clippy-issue-single-char-names
$ echo 'single-char-binding-names-threshold = 0' > clippy.toml
$ cargo clippy -- -D warnings
    Checking clippy-issue-single-char-names v0.1.0 (/path/to/clippy-issue-single-char-names)
error: 0 bindings with single-character names in scope
  |
  = note: `-D clippy::many-single-char-names` implied by `-D warnings`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names

error: aborting due to previous error

error: Could not compile `clippy-issue-single-char-names`.

To learn more, run the command again with --verbose.

I know that it worked a few months back but I cannot tell you when exactly it stopped working as I haven't programmed in a while..

If I set the value to 1, then clippy does not complain, so I guess there's a wrong >= instead of just > somewhere..

clippy version:

$ cargo clippy -V
clippy 0.0.212 (3710ec5 2019-05-11)

Edit/Note: I can't reproduce this if I clone rust-clippy and run clippy from this repository, so maybe/probably this was already fixed since the last release?

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions