-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Make level
field optional in the [lints]
table
#13934
Conversation
src/cargo/util/toml/mod.rs
Outdated
if config.level().is_none() && config.config().map(|c| c.is_empty()).unwrap_or(true) { | ||
anyhow::bail!("`lints.{tool}.{name}` missing field `level`"); | ||
} |
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 is the big question for me: what should be allows
Today
lint_name = {} # disallowed
lint_name = { config_name = "config_value" } # disallowed
lint_name = { priority = 1 } # disallowed
lint_name = { priority = 1, config_name = "config_value" } # disallowed
lint_name = { level = "warn" } # allowed
lint_name = { level = "warn", priority = 1 } # allowed
With this PR
lint_name = {} # disallowed
lint_name = { config_name = "config_value" } # allowed
lint_name = { priority = 1 } # disallowed
lint_name = { priority = 1, config_name = "config_value" } # allowed
lint_name = { level = "warn" } # allowed
lint_name = { level = "warn", priority = 1 } # allowed
This allows priority
without level
. Should we allow that?
This requires level
or config, should we bother with an empty table error?
I almost lean towards either keeping the requirement on level
or dropping all requirements (though priority
alone feels weird).
Thoughts?
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 allows
priority
withoutlevel
. Should we allow that?
I don't think so, if priority
is set then level
must also be set, that's a oversight on my part. Will fix it.
This requires
level
orconfig
, should we bother with an empty table error?
My stance is that it is useless and weird to have empty table.
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.
Fixed the priority
field alone without the level
field. It now bail out.
658db82
to
cc345e4
Compare
We talked about this in today's Cargo team meeting and decided to defer this out.
|
What does this PR try to resolve?
This PR makes the
level
field in the individual lint under the[lints]
optional if some other key (exceptpriority
since it would make sense to have it alone) is defined. The goal is to avoid a empty lint definition.This is to allow special configs like
check-cfg
in theunexpected_cfgs
to omit thelevel
field.Users would now be able to omit the
level
field, resulting in:How should we test and review this PR?
Test putting removing the
level
field with/without this PR.Reviewing this PR should be straightforward, look at the tests that change to see the effect of this change.
Additional information
#13913 (comment)
r? @epage