-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Clippy ignores feature = "cargo-clippy"
in generated code
#12392
Comments
Oh I see what is going on here. But the bad news is, that we can't fix this: To catch The reason why this lint after macro expansion is pretty straightforward: After the |
@Urgau Does the EDIT: Just tested this (sorry for the premature ping) and it works with generated code:
So you would get this error message once the |
@flip1995 No worries. Internally check-cfg is implemented directly at the evaluation phase of the configs, it is therefor able to catch all cfgs, no matter where they are coming from: I unfortunately don't see an easy way for Clippy to hook itself there. |
Ah, makes sense. I suppose you could add a pass that runs after the expansion of each macro, at a performance cost that scales with the number of macros. It’s probably a small cost, but… bleh. This must affect all of the lints in rust-clippy/clippy_lints/src/attrs.rs Lines 870 to 880 in 346b094
I usually turn down linting for generated code anyway, so it seems like fixing this probably isn’t worth the effort. Is this worth pursuing, or should this issue just be closed? |
This would actually be a huge cost, as it would have to run after every IMO this issue can be closed. We can't fix this in Clippy and once |
Summary
The
deprecated_clippy_cfg_attr
lint does not seem to work in generated code. I have confirmed that other lints are working, and that the lint works on code insrc/lib.rs
.Reference: PR #12292 — Add new lint
DEPRECATED_CLIPPY_CFG_ATTR
.Lint Name
deprecated_clippy_cfg_attr
Reproducer
cargo init . --name foo --lib
build.rs:
src/lib.rs:
Actual results
This catches the use of
feature = "cargo-clippy"
insrc/lib.rs
, and one of the comparisons in the generated code, but does not warn about the use offeature = "cargo-clippy"
in the generated code.Expected results
Version
The text was updated successfully, but these errors were encountered: