rust-lang / rust-lang/rust-clippy
`allow` only works with some lints if and only if they're allowed both in the crate root and in the desired module
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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 (1c6868aa 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running cargo clippy on the two-file main.rs and foo.rs reproduction. Compare single_component_path_imports and items_after_statements with enum_glob_use and match_same_arms, then trace how their module-level allows are handled. Done means the affected lints respect an allow in the desired module without requiring one in the crate root, with a regression test covering the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100