-
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
Extend maybe_misused_cfg
lint over cfg(test)
#11821
Conversation
maybe_misused_cfg
lint over cfg(test)
1966d0d
to
b9eb3c5
Compare
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.
Pretty good first iteration (^・o・^)ノ”
b9eb3c5
to
55d298a
Compare
Thanks for the improvements, updated! |
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.
Wonderful ❤️
} else if let Some(ident) = meta.ident() | ||
&& matches!(ident.name.as_str(), "tests" | "Test") |
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.
Instead of deny-listing tests
and Test
, would it be possible to allow-list all configs passed in by --cfg
plus the built-in ones (test
, debug_assertions
, …)?
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'll check for the full list then.
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 back to this, I'm not sure it's a good approach because you might use a valid cfg
that is not passed to the compiler (so it's cfg
ed-out) and in this case it would be considered as an error since this cfg
isn't known to clippy. So false-positive.
However on the other hand, it's already possible to have this issue currently, so not sure if we want to dive into this any further.
I think a next iteration on this would be to eventually check for all existing ones (the builtin ones and the ones provided to rustc) but we need to check pros and cons.
Does that sound acceptable?
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.
You are right; catching all cfg
errors is definitely a different and much larger issue
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.
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.
Yes it is. I discovered it afterwards and I linked to the tracking issue in my last comment of this PR.
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.
Just a nit and I think this is merge-ready! (With Emil's review)
55d298a
to
f08037c
Compare
I applied suggestions except one which I think deserves more discussion and should happen in a follow-up PR. What do you think? |
@bors r+ |
Extend `maybe_misused_cfg` lint over `cfg(test)` Fixes #11240. One thought I had is that we could use the levenshtein distance (of 1) to ensure this is indeed `test` that was targeted. But maybe it's overkill, not sure. r? `@blyxyas`
💔 Test failed - checks-action_test |
I added the missing changelog in my first comment. Sorry about that. |
@bors retry |
@bors r+ |
💡 This pull request was already approved, no need to approve it again.
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
I was planning to open an issue to have a discussion about a wider check for all But luckily for us, I just learned that the |
Here's the issue: rust-lang/rust#82450 |
…yxyas Improve maybe misused cfg Follow-up of the improvements that were suggested to me in #11821: * I unified the output to use the same terms. * I updated the code to prevent creating a new symbol. r? `@blyxyas` changelog: [`maybe_misued_cfg`]: Output and code improvements
Fixes #11240.
One thought I had is that we could use the levenshtein distance (of 1) to ensure this is indeed
test
that was targeted. But maybe it's overkill, not sure.changelog: [
maybe_misused_cfg
]: Extend lint overcfg(test)
r? @blyxyas