-
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
Add MINIMAL_CFG_CONDITION
lint
#10763
Conversation
r? @Jarcho (rustbot has picked a reviewer for you, use r? to override) |
c1a1c3a
to
d414d8f
Compare
Surprisingly, I needed to update one ui test locally but I had to revert this change because the updated output fails in the CI. |
As-is, this lint does not emit any output for empty lists Note that sometimes |
It is intentional to not handle empty
Do you have some examples by chance? |
#[cfg(any())]
fn uwu() {
let () = 1; // type error
let b = a; // use missing identifier
"a" - 100.0 == Vec // it parses, but definitely not valid
}
// redefinition doesn't cause an issue since the other one doesn't exist
fn uwu() {
// let's try an alternate implementation without updating any other code
// or needing to delete the old code
} Code that's cfg'd out only has to parse, but otherwise doesn't act like it exists at all. Sometimes this is useful for seeing if parts of code are needed, or for swapping out implementations for testing without needing to handle multiline comments or deleting the code. It's probably a moderately uncommon use of |
I see. Well then, definitely better to not lint about this part. So I suppose the current lint is valid then since it doesn't prevent this use of |
☔ The latest upstream changes (presumably #10691) made this pull request unmergeable. Please resolve the merge conflicts. |
A name like
|
d414d8f
to
e3ad36c
Compare
UNIQUE_CFG_CONDITION
lintMINIMAL_CFG_CONDITION
lint
I fixed the merge conflict, updated the lint name to |
Looks like I was wrong and failed predicates do appear in the AST. It's only the HIR tree they don't appear in. It would be best to ignore |
e3ad36c
to
175e6a4
Compare
Only kept the check for |
175e6a4
to
94db4b0
Compare
94db4b0
to
dbc76a7
Compare
You have failing |
I split the test in 2 where I kept the "fixable" one in the first file and the |
Yep, CI is happy now. \o/ |
Looks good. Thank you. @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
I encountered a few cases where some code had:
#[cfg(any(unix))]
In this case, the
any
is useless. This lint checks this and also for theall
condition.