Skip to content

Conditional compilation for configuration file? #11433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ojeda opened this issue Aug 30, 2023 · 0 comments
Open

Conditional compilation for configuration file? #11433

ojeda opened this issue Aug 30, 2023 · 0 comments

Comments

@ojeda
Copy link
Contributor

ojeda commented Aug 30, 2023

Some lints that are configured via clippy.toml may need to react to conditional compilation.

For instance, for disallowed_macros, a project may want to warn only about a particular macro in some configurations (e.g. CI vs. development).

It could also be useful if Clippy were to identify unexpected paths to prevent mistakes (#11432), since it would allow the user to e.g. remove a given macro from the list if the macro is compiled out.

A workaround could be users generating Clippy's config file on the fly.

Perhaps Clippy could instead allow to be configured within the Rust source code (step-by-step), so that the #[cfg] syntax/machinery is reused, but I imagine there is a reason it was not done there (e.g. workspaces sharing config easily?), e.g.

// `m1` always disallowed.
#[clippy_config(disallowed_macros, "m1")]

// `m2` only disallowed if `X`.
#[cfg(X)]
#[clippy_config(disallowed_macros, "m2")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant