-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] Configure lints in Cargo.toml #5728
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@detrumi I saw your message on Discord, did you figure out the virtual manifest distinction? There are two manifest types, I'd caution about having packages override the workspace, since that's the opposite precedence of other workspace settings. I'm not sure how that should work. Also, just a heads up, rustdoc lint settings will probably be stabilized soon (rust-lang/rust#52354), and will probably want to reuse these for rustdoc. (Which will also probably need cap-lint support, but I imagine that will land separately.) One tricky bit is that This will likely need a feature flag (see |
☔ The latest upstream changes (presumably #5726) made this pull request unmergeable. Please resolve the merge conflicts. |
49d2614
to
68ae5b1
Compare
@ehuss Thanks for pointing me to The package override direction was taken from the proposal text in #5034, but maybe I read that wrong or there was a mistake in that, since you're right that having workspaces override packages makes more sense. I'll look into the |
I don't think you misread it, different people will have different expectations. I'm not sure which way is the right way. I'm just cautioning that it may not be clear how it should work, and that someone on the cargo team might want to clarify it. |
ping @detrumi, have you had a chance to handle some of the follow up comments here? |
@alexcrichton Yes, I'm slowly working my way through implementing it. |
69fb5a4
to
4652dca
Compare
Some questions:
|
Others may have a better idea how to handle the flags and such but for the test at least it's been tweaked I think since this started, you should be able to just drop the leading |
tests/testsuite/lints.rs
Outdated
@@ -0,0 +1,177 @@ | |||
use cargotest::support::{execs, project}; |
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 cargotest::support
module is now just support
, as of #5762.
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.
Thanks, didn't expect that not rebasing would cause such issues
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.
Yeah it does because CI tests the merge of this PR branch with the (current) state of the target branch (where the merge has happened).
cd7dbf6
to
67ee176
Compare
@@ -240,6 +241,9 @@ pub struct TomlManifest { | |||
patch: Option<BTreeMap<String, BTreeMap<String, TomlDependency>>>, | |||
workspace: Option<TomlWorkspace>, | |||
badges: Option<BTreeMap<String, BTreeMap<String, String>>>, | |||
lints: Option<BTreeMap<String, String>>, | |||
#[serde(rename = "lints2")] |
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'm not entirely clear on what the lints2
name is doing here, can you add a comment to the naming choice 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.
Ah, I haven't figured out yet how to deserialize both [lints]
and [lints.'cfg(...)']
correctly, so I just temporarily named it something else (sorry!). Just using #[serde(rename = "lints")]
here doesn't work, so it probably needs a custom Deserialize impl.
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.
Hm ok, I'm not really sure we'd want to support cfg(..)
for lint configurations though in the sense that it feels like it's a bit overkill for configuration that can otherwise be specific in the crate source anyway?
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.
Right, let's simplify to just a [lints]
section then.
pub fn set_lint_flags(&self, unit_cfg: &[Cfg], features: &HashSet<String>, cmd: &mut ProcessBuilder) { | ||
match self.cfg { | ||
None => self.set_flags(cmd), | ||
Some(CfgExpr::Value(Cfg::KeyPair(ref key, ref value))) |
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 think we've already got a number of #[cfg]
matching functions throughout Cargo, could those be reused 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.
I don't see one that could be used here, except maybe the CfgExpr::matches
function that is used in the next line. The way I wrote it seems simpler than wrapping all feature strings inside Cfg::KeyPair
, unless feature = foo
keypairs can be nested inside other CfgExpr
's?
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 think we'll want to funnel everything through matches
to ensure it's consistently appplied
88e21f8
to
09abcb6
Compare
09abcb6
to
e6a64ea
Compare
Hiya @detrumi, are you still working on this? |
This is unfortunately pretty old at this point so I'm going to close this (and we also have a soft feature freeze right now with Cargo). The Cargo team, however, will hopefully be able to allocate resources for this in early 2019! |
@detrumi Would you mind if I pick up this PR in the next days? I would really like to see this implemented in 2019. (I would probably start with a fresh PR) |
@phansch We discussed lint configs at the Cargo meeting yesterday. We would like to see more discussion on the design before continuing. Would you be interested in helping to hash this out on IRLO? The following needs a closer look:
We don't really feel this needs a full RFC process, but we would at least like to see the content/questions that arise during that process to be addressed. |
Yes, feel free to work on this. Creating a post on IRLO seems like a good way to push this forward, as there are too many open questions. I'd be happy to help, but I don't have much experience pushing discussion forward and such. |
Implements #5034
This PR adds a
[lints]
section toCargo.toml
using the following format:Progress
-A
/-W
/-D
/-F
flags to rustc[lints.'cfg(feature = "clippy")']