rust-clippy
rust-clippy copied to clipboard
New Lint: disallowed_macro
What it does
Disallows certain macros, as defined in clippy.toml.
Equivalent to the disallowed_method
lint, but for macros instead of methods.
Drawbacks
It may be cleaner to add support for macros to the existing disallowed_method
lint.
Example
# clippy.toml
disallowed-macros = ["eyre::anyhow"]
...
let f = eyre::anyhow!("foobar");
...
results in a lint.
@rustbot claim
I can't figure out how to do this. With an EarlyLintPass
the macro's have been resolved, but LateLintPass
is after theyve been expanded, so I'm not sure if this is possible.
LMK if I've missed anything, and anyone wants to try this you might find my attempt usefull
@aDotInTheVoid This should be possible with EarlyLintPass
. The macros are expanded either way. You basically are just looking at the Span
(like expr.span
) to see if it is from an expanded macro. Here is an example.
I would like to give this a go @rustbot claim
Hi, apologies. Life has got in the way and I don't think I'll be able to work on this soon. Will unclaim in case someone else wants to.
@rustbot release-assignment