Skip to content
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

New Lint: disallowed_macro #7790

Closed
JamesHinshelwood opened this issue Oct 8, 2021 · 5 comments · Fixed by #9495
Closed

New Lint: disallowed_macro #7790

JamesHinshelwood opened this issue Oct 8, 2021 · 5 comments · Fixed by #9495
Assignees
Labels
A-lint Area: New lints

Comments

@JamesHinshelwood
Copy link
Contributor

JamesHinshelwood commented Oct 8, 2021

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.

@JamesHinshelwood JamesHinshelwood added the A-lint Area: New lints label Oct 8, 2021
@aDotInTheVoid
Copy link
Member

@rustbot claim

@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Oct 10, 2021

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 aDotInTheVoid removed their assignment Oct 10, 2021
@camsteffen
Copy link
Contributor

@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.

@JamesHinshelwood
Copy link
Contributor Author

I would like to give this a go
@rustbot claim

@JamesHinshelwood
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants