Similar to #158371, I found that the redundant_imports lint does not work in modules that are defined in any macros. This is especially relevant since this also affects cfg_if! and cfg_select! which are often used to define modules (e.g., #158252).
Interestingly, other lints seem to work just fine, so this seems specific to the work that redundant_imports needs to do to analyze imports.
Reproduction
lib.rs:
#![deny(redundant_imports)]
#[cfg(true)]
pub mod foo; // works
macro_rules! identity {
($($tt:tt)*) => {
$($tt)*
};
}
identity! {
// pub mod foo; // does not work
}
cfg_if::cfg_if! {
if #[cfg(true)] {
// pub mod foo; //does not work
}
}
cfg_select! {
_ => {
// pub mod foo; // does not work
}
}
foo.rs:
use std::option::Option::None;
pub fn foo() -> Option<i32> { None }
Command:
Similar to #158371, I found that the
redundant_importslint does not work in modules that are defined in any macros. This is especially relevant since this also affectscfg_if!andcfg_select!which are often used to define modules (e.g., #158252).Interestingly, other lints seem to work just fine, so this seems specific to the work that
redundant_importsneeds to do to analyze imports.Reproduction
lib.rs:foo.rs:Command: