-
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
Turn declare_clippy_lint into a declarative macro #13359
Conversation
7fbe95f
to
f58aae5
Compare
Maybe: |
Recompile time seems pretty similar, maybe try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be in the clippy_utils
crate, as this is not something users of that crate should use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should it be in clippy_lints/lib.rs
? Or somewhere else maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In clippy_lints
probably yeah. But not necessarily in lib.rs
. But lib.rs
should at least re-export it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving it from clippy_utils
to clippy_lints
would need prepending all lint files with use crate::declare_clippy_lint
. It can be done a simple bash script, but is it what we want?
I'm not sure why this isn't the case anymore, but when the macro was in clippy_utils
just auto-imported it into the lint modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because of #[macro_use]
rust-clippy/clippy_lints/src/lib.rs
Lines 61 to 62 in 78bdd45
#[macro_use] | |
extern crate clippy_utils; |
To do the same for a local macro you can either #[macro_export]
it or put it in a #[macro_use]
module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's because of the #[macro_use]
, but giving it to another module is not working. (I've tried both with all combinations of #[macro_export]
on the macro and #[macro_use]
on the module)
I've tried both in clippy_lints/lib.rs
, in a separate file and in the clippy_lints::utils
module. Still, not working :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh there's also that it needs to be defined above the lint modules that use the macro for some reason
Before using paste, I tried with
In the common |
|
Fixed, I didn't know about ${concat}, seems very useful (and possibly a general replacement for paste!) |
a63f367
to
f58aae5
Compare
Oh, something I forgot to mention. The main motivator behind this change is rust-lang/rust#125116. I need to mark some lints as always evaluated (so that, even if they are allow by default and are not manually triggered, they still run). The proc macro API is hard to work with, and I wasn't getting to the point of accepting "[eval_always: true]" into the proc macro optionally. That's the reason I translated it, and most of the reason. |
☔ The latest upstream changes (presumably #13440) made this pull request unmergeable. Please resolve the merge conflicts. |
rustc_session::declare_tool_lint! { | ||
$(#[doc = $lit])* | ||
#[clippy::version = $version_lit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is a bit off here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parts in declare_tool_lint! {
should be indented
c4d3198
to
d562708
Compare
d562708
to
4997ee7
Compare
9e840fa
to
13e2633
Compare
Is there anything more to be done? I'm waiting for the merge & sync to resolve this conversation |
👍 @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Ease of development, and hopefully compile times (the dependencies are still there because of ui-test). The procedural macro was doing just some very basic processing (like assigning a lint level to each category), so it didn't have a reason to stay IMO
changelog: None