Hello, there's some compute-heavy calculation within one of the lints, which i am working on, and i want to skip the calculation if the lint is allow
-ed. I wonder what's the proper way to do this detection? Thanks!
Clippy has a helper for it: https://github.com/rust-lang/rust-clippy/blob/9a3b0a05888f7ad002b67bbe61739695967ce929/clippy_lints/src/utils/mod.rs#L1069
I think you can just copy it to your code, as that one liner is probably not useful to be copied to rustc
Thanks! I'm working with an early ctx lint though, but it's similar. i think i've worked my way out. I just need to extract a method within https://github.com/rust-lang/rust/blob/master/src/librustc_lint/levels.rs .
don't lints automatically get that?
like, I thought the entire point of declare_lint_pass!
was to only run the pass if the lint is enabled
no, we always run all lint passes, the association with the lints they emit isn't actually used at all
well, it's how those lints get registered
but we could just as easily have them separate
and you can totally emit other lint passes' lints from your lint pass
oh
to be clear, I think this is probably a "bug" at some level, we should perhaps fix it
rustc actually merges all lint passes IIRC into one for performance reasons