Skip to content

allow only works with some lints if and only if they're allowed both in the crate root and in the desired module #7290

Open
@T-Dark0

Description

@T-Dark0

I tried this code:

// in main.rs
#![warn(clippy::all, clippy::pedantic)]

mod foo;

fn main() {
    foo::foo();
}

//in foo.rs
#![allow(clippy::single_component_path_imports)]

pub fn foo() {
    usable!();
}

macro_rules! usable {
    () => {};
}
use usable;

I expected to see this happen: The lint is silenced for the module

Instead, this happened: The lint was not silenced, and fired anyway in the output of cargo clippy

It may be worth mentioning that the lint is silenced if and only if the allow exists both in the crate root and in the module

This bug also occurs with other lints, but does not occur with all lints: I've been able to cause it with items_after_statements, but not with enum_glob_use or match_same_arms. In the case of the latter two, the lint was silenced for the module without the need to allow it in the crate root as well.

Meta

  • cargo clippy -V: clippy 0.1.54 (1c6868a 2021-05-27)
  • rustc -Vv:
rustc 1.54.0-nightly (1c6868aa2 2021-05-27)
binary: rustc
commit-hash: 1c6868aa21981b37cbd3fc95828ee3b0ac22d494
commit-date: 2021-05-27
host: x86_64-pc-windows-msvc
release: 1.54.0-nightly
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions