Open alexcrichton opened 6 years ago
I don't know if this is solvable in general.
Or are you asking for not squashing the lint behind macros? That's easy, just add report_in_external_macro: true
to https://github.com/rust-lang/rust/blob/c7cba3d33f564be140275c4fb9e33c6dc2c97b21/src/librustc_lint/builtin.rs#L1392-L1396
I'm also not sure it's solvable! It may be a bit of a red herring here to say this is related to macro quashing, it's just sort of hiding the real bug.
I think a better way to put this may be that:
unreachable_pub
lint's suggestions don't work unless you apply all the suggestions.lazy_static!
's generated static). In the macro above there's no way to use crate
visibility.unreachable_pub
may not provide correct suggestions.The macro quashing is meaning you don't even see one of the suggestions (the one in the macro invocation), but even if we display the lint it wouldn't be actionable by rustfix anyway.
So...
For each lint candidate that has not been squished:
This is a bit extreme and might lead to loads of false negatives, so we should check to ensure that
mod bar {
#[derive(Debug)]
pub struct FOO;
}
fn main() {
println!("{:?}", bar::FOO);
}
still lints.
Recently we landed a change which squashes all lints tied to foreign macros, but this can thwart lints like
unreachable_pub
in unusual fashions. Theunreachable_pub
lint can't be fixed unless all its warnings are fixed, which means the following examples fails to compile after being fixed:and then
compiled with:
but the corrected code doesn't compile!
This is a reuced example where
a!
islazy_static!
, but I believe the issue here is that the lints behind thelazy_static!
invocation are being ignored which means thatFoo
is actually fully public (becauseF
is) and the lint is no longer applicable as a result.cc @Manishearth, @oli-obk