Why is this an issue?

Lint attributes on crate imports and use statements have no effect and may indicate a misunderstanding or mistake in the code. This can lead to confusion or unintended behavior.

Code examples

Noncompliant code example

#[deny(dead_code)]
extern crate foo;

#[forbid(dead_code)]
use foo::bar; // Noncompliant: Lint attributes are ineffective on imports.

Compliant solution

#[allow(unused_imports)]
use foo::baz;

#[allow(unused_imports)]
#[macro_use]
extern crate baz; // Compliant: Example with appropriate usage.

Resources

Documentation