-
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
Close the front door for clippy but open the back #7533
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Feeling pretty good about this PR atm, the biggest problem right now is that I broke rustfix isolation, so now its fixing the non relevant crates. I think this is because I didn't scope the fixing to primary units like how I adjusted things in an earlier change, and rustfix probably had some separate hacky way of telling it to only fix primary crates, where as my last changes made it so we just invoke rustc rather than I'm also kinda confused on whether or not I should be using the term To continue with the pattern we've established here I think we need a |
Ah, sorry about being vague there. To be clear, "primary packages" are those selected on the command line. For example, I think that opens the question on how clippy should work. And maybe how
So I guess the question boils down to, do you want to see clippy lints for dependencies in a workspace? I don't have a good answer. The primary package seems more useful (think of a workspace like I have to leave for a while, but I'll try to do some more review here tonight. |
I definitely prefer it to run against all workspace crates, but not necessarily path dependencies, which is something I think it currently does. I've had cases where I checked out a git repo for an unpublished crate and depended on it with a path dep and it surfaced clippy lints which was not what I wanted. I'm not actually sure how cargo differentiates between these two cases. Ive only seen things talking about primary crates in the source, so I'll have to figure out how it deliniates crates that are in the workspace specifically. I'll look into filtering by workspace members for clippy and move forward with the assumption that this is how we want to filter application of the alternate rustc unless I get comments to the contrary. I'll make sure to keep fix on primaries and try to add some test cases that configure various forms of projects with path deps, workspace members, primary crates specified on the cli when called, etc. |
Ideally I think the answer would be "all workspace projects, unless you've specified a single one via |
Path dependencies are automatically added as workspace members. This can be overridden by setting the
Workspace members are computed in
Cargo doesn't really have this kind of distinction. If you don't specify I think this is essentially rust-lang/rust-clippy#3025, right? I don't have any good answers on how to address this. Maybe we could set an env var that the clippy wrapper could detect (and the clippy wrapper could maybe have a (Sorry, running out of energy for today, will try to look closer at the code tomorrow.) |
I don't think it's a big deal if we can't solve clippy#3025 right now; I'd rather get this to work for workspaces and figure that out later |
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.
Seems pretty close. Just to be clear, I think the precedence of which rustc is used would be:
BuildConfig.primary_unit_rustc
RUSTC_WORKSPACE_WRAPPER
RUSTC_WRAPPER
RUSTC
rustc
in path
Where primary_unit_rustc
is only used by cargo fix
to set cargo itself as the wrapper.
Also, we'll probably want to remove clippy from CI (azure-test-all.yml
), as I think it will no longer be needed.
☔ The latest upstream changes (presumably #7550) made this pull request unmergeable. Please resolve the merge conflicts. |
97b2a4f
to
175238d
Compare
src/cargo/util/rustc.rs
Outdated
.filter(|wrapper| !wrapper.get_program().is_empty()) | ||
.map(|wrapper| { | ||
let mut cmd = wrapper.clone(); | ||
// TODO: FIX HACK |
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 where having the primary_unit_rustc exist as a wrapper becomes a problem. cargo fix
doesn't really want to use the rustc_wrapper
either, it's only supposed to run fix for primary units so it makes sense to invoke it via the primary wrapper, but when you do that it turns it into a wrapper by adding the path (rustc) as an arg, but for fix we already added the path to the wrapper so you end up with cargo clippy-driver rustc ...
at the end. This check prevents that extra incorrect insert from happening but we need to find a better way to do this.
IIUC, this is moving in a slightly different direction where it is only running against primary units, not all workspace packages, correct? If that is true, calling it a "workspace wrapper" may not be entirely correct. I'm also not sure if that is what @Manishearth wanted (the message at #7533 (comment) seemed to imply all workspace crates is preferred). I'd also be a little concerned this is encroaching on the concerns from #7205 (comment), where "primary" isn't well established.
Not really. Whichever approach is taken, it would be good to have some tests for the new behavior. |
Yeah, I think we wanted:
- all workspace packages, if run from workspace root
- all workspace packages being compiled, if run from a specific crate
…On Thu, Nov 21, 2019, 5:45 PM Eric Huss ***@***.***> wrote:
IIUC, this is moving in a slightly different direction where it is only
running against primary units, not all workspace packages, correct? If that
is true, calling it a "workspace wrapper" may not be entirely correct. I'm
also not sure if that is what @Manishearth
<https://github.com/Manishearth> wanted (the message at #7533 (comment)
<#7533 (comment)>
seemed to imply all workspace crates is preferred). I'd also be a little
concerned this is encroaching on the concerns from #7205 (comment)
<#7205 (comment)>,
where "primary" isn't well established.
primary packages are strictly a subset of the workspace ones
Not really. -p can be specified for any package.
Whichever approach is taken, it would be good to have some tests for the
new behavior.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7533?email_source=notifications&email_token=AAMK6SFUNEPRYATHES4IAI3QU42R7A5CNFSM4JDRBOY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE4H3TQ#issuecomment-557350350>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMK6SDEHYJBLX742EMKMLTQU42R7ANCNFSM4JDRBOYQ>
.
|
Okay, yea I wasn't sure if we decided that primary crates were close enough to workspace crates or if we wanted to intentionally aim at workspace crates. In that case I shall figure out an |
☔ The latest upstream changes (presumably #7628) made this pull request unmergeable. Please resolve the merge conflicts. |
397d6b5
to
7caefed
Compare
☔ The latest upstream changes (presumably #7710) made this pull request unmergeable. Please resolve the merge conflicts. |
7caefed
to
4d999a6
Compare
☔ The latest upstream changes (presumably #7776) made this pull request unmergeable. Please resolve the merge conflicts. |
4d999a6
to
4fc11a4
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.
Thanks! I think this is getting pretty close. Some notes:
- There should be some kind of test in
testsuite/cache_messages.rs
that verifies when the workspace wrapper is set that it rebuilds compared to when it is not set (essentially the same as the old clippy test). The wrapper will just need to emit some extra output. - Windows build is broken.
- The notes at the bottom of Close the front door for clippy but open the back #7533 (comment) still need to be addressed.
Also, have you tested with sccache to see if it works with clippy?
☔ The latest upstream changes (presumably #7838) made this pull request unmergeable. Please resolve the merge conflicts. |
c53f61a
to
b0351e4
Compare
OK! I think this looks good overall. Thanks so much for sticking with it @yaahc! Do you want to work on the clippy side to enable this? I think there are two things to do:
Unfortunately I don't see a way to check if clippy is on the nightly channel in the clippy codebase, but maybe it can access There's no rush. The rust PR queue is somewhat backed up, so it may take a couple weeks for this to land on nightly. @bors r+ |
📌 Commit d9a77ce has been approved by |
☀️ Test successful - checks-azure |
Update cargo Update cargo 21 commits in bda50510d1daf6e9c53ad6ccf603da6e0fa8103f..7019b3ed3d539db7429d10a343b69be8c426b576 2020-03-02 18:05:34 +0000 to 2020-03-17 21:02:00 +0000 - Run through clippy (rust-lang/cargo#8015) - Fix config profiles using "dev" in `cargo test`. (rust-lang/cargo#8012) - Run CI on all PRs. (rust-lang/cargo#8011) - Add unit-graph JSON output. (rust-lang/cargo#7977) - Split workspace/validate() into multiple functions (rust-lang/cargo#8008) - Use Option::as_deref (rust-lang/cargo#8005) - De-duplicate edges (rust-lang/cargo#7993) - Revert "Disable preserving mtimes on archives" (rust-lang/cargo#7935) - Close the front door for clippy but open the back (rust-lang/cargo#7533) - Fix CHANGELOG.md typos (rust-lang/cargo#7999) - Update changelog note about crate-versions flag. (rust-lang/cargo#7998) - Bump to 0.45.0, update changelog (rust-lang/cargo#7997) - Bump libgit2 dependencies (rust-lang/cargo#7996) - Avoid buffering large amounts of rustc output. (rust-lang/cargo#7838) - Add "Updating" status for git submodules. (rust-lang/cargo#7989) - WorkspaceResolve: Use descriptive lifetime label. (rust-lang/cargo#7990) - Support old html anchors in manifest chapter. (rust-lang/cargo#7983) - Don't create hardlink for library test and integrations tests, fixing rust-lang/cargo#7960 (rust-lang/cargo#7965) - Partially revert change to filter debug_assertions. (rust-lang/cargo#7970) - Try to better handle restricted crate names. (rust-lang/cargo#7959) - Fix bug with new feature resolver and required-features. (rust-lang/cargo#7962)
Remove clippy tests. Clippy was removed in #7533, but a stale file was left behind.
would have be nice to report this change in the changelog. matching the "Added cargo fix --clippy which will apply machine-applicable fixes from Clippy. #7069" in the change log. |
@Stargateur The changelog is updated 6 weeks before release. It will probably be updated next week for the release in June. Also, this isn't the complete solution. rust-lang/rust-clippy#5363 will need to be merged first, and then it will need to go through the stabilization process, so there isn't much to say in the changelog other than clippy-preview was removed. |
@ehuss It would have remove the pain to understand why stable ask for nightly and then nightly say the option doesn't exist. And maybe that before merge this have the rust-lang/rust-clippy#5363 ready to merge too would have been better. Anyway I never used this option so /me fly away. (Also, the actual (nightly) build doesn't have the option so I don't understand your "It will probably be updated next week for the release in June." there is a miss somewhere in your organisation) |
No description provided.