Rust-clippy: allow many_single_char_names is broken

Created on 19 Sep 2018  路  11Comments  路  Source: rust-lang/rust-clippy

Playground:

#[cfg_attr(
    feature = "cargo-clippy",
    allow(clippy::many_single_char_names)
)]
pub fn append_to() {
    let (a, b, c, d, e) = (0, 0, 0, 0, 0);
}

produces

warning: 5th binding whose name is just one char
 --> src/main.rs:7:22
  |
7 |     let (a, b, c, d, e) = (0, 0, 0, 0, 0);
  |                      ^
  |
  = note: #[warn(clippy::many_single_char_names)] on by default
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#many_single_char_names

That lint should not trigger, since it is allowed for the function.

P-needs-test good-first-issue

All 11 comments

Applying the allow to a function does not change the behavior of the lint inside the function. This is weird, since the lint is produced through EarlyLintPass::check_[impl_]item() and a function is an item.

It works if you turn the cfg_attr into an inner attribute. Probably something you don't want to do.

Removing the clippy:: and checking this with cargo +stable clippy doesn't produce a warning. I'm afraid that this could have something to do with tool_lints...

I'm hitting this issue with other lints like shadow_unrelated as well. Moving the cfg_attr into an inner attribute does not work around this form me, can you show on the play ground how you are doing that ? This still produces the warning for me:

pub fn append_to() {
    #![cfg_attr(
        feature = "cargo-clippy",
        allow(clippy::many_single_char_names)
    )]
    let (a, b, c, d, e) = (0, 0, 0, 0, 0);
}

Sure: Playground

#![feature(tool_lints)]

#![cfg_attr(
    feature = "cargo-clippy",
    allow(clippy::many_single_char_names)
)]

#[allow(unused_variables)] 
pub fn main() {
    let (a, b, c, d, e) = (0, 0, 0, 0, 0);
}

Hm maybe something changed how lint attributes are processed... Since when do you have these issues?

Ah, you meant making it an inner attribute of the scope where the function is, yeah I'd prefer not to do that. I've just disabled the lint globally as a workaround for now.

Since when do you have these issues?

I just started updating criterion to the latest clippy, and the last Rust nightly version criterion used was from june... so... I'd guess between june and today, which isn't probably very helpful.

I'm looking into that!

This error started with nightly-2018-08-24. The previous nightly-2018-08-19 does not produce a warning for your example. (That means, it is not connected to the tool_lints :tada:)

Repo: https://github.com/flip1995/test_allow_on_fn
Travis: https://travis-ci.org/flip1995/test_allow_on_fn/builds/430632901

This is no longer an issue: Playground

Is there a test that prevents this from breaking again?

Oh good point!

Was this page helpful?
0 / 5 - 0 ratings