-
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
check subcommand should force rebuild #6664
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. |
It looks like three tests failed, but only on nightly. I'm going to look into this, but any ideas of what could be the cause here?
-- edit -- I see now that all three of those tests have a code block which returns early if not running nightly. So I suspect these tests would have failed for all versions of Rust if not for that. I'll work on fixing them up. As a side note, they say they should be removed once 1.27 is stable. Should we just remove these early returns now? if !is_nightly() {
// This can be removed once 1.27 is stable, see below.
return;
} |
The latest commit should fix these tests, assuming we want to remove the early return for |
I don't think most users expect If we agree |
@dwijnand I was pretty surprised to discover that As long as this PR doesn't change the behavior of |
It's surprising to users not because of any interactions with |
Yes, I should have said users expect to see the error messages each time, so I think cacheing these warnings would be great. Any tips on implementing this cacheing? I'm new to the cargo codebase so I'm not sure how cacheing is typically handled. |
I don't know exactly but cargo process calls rustc, and does so via a rustc wrapper, so finding that will get you half way to before it executes it. Then you need to go to the place where it uses the fact that the build artefacts are "fresh" to avoid compile to display the warnings you cached. If I can find more specific code locations I'll recomment. |
@dwijnand: |
cargo build; cargo check; cargo build should behave differently, |
Right, I said "compile" as short-hand, but you're right it stops earlier in the pipeline, running (what's commonly referred to as) the frontend of the compiler.
|
@dwijnand: I agree it should redisplay warnings then, but by default, since I claim it'd be the expected behavior. Since running the first steps in the compilation pipeline is supposed to be low-cost, the desired default behavior would be easily implemented by not reusing previous build results. |
I think it's low-cost compared to a full |
But it's called 'check', when you run that explicitly, it's reasonable some cost is incurred. To the contrary, it's not reasonable e.g. |
While I can agree with the later, I'd consider it a performance regression if I'm optimistic we can find a way to cache and uncache warnings without changing the freshness behaviour. |
it looks like Eric Huss has some pointers; see the links in his comment here: https://internals.rust-lang.org/t/clippy-behavior-affected-by-incremental-compilation/9436/2?u=batmanaod @sanmai-NL : Yes, I was asking specifically about the last part of the sequence, the second
...hold on, that's surprising to me. If |
It uses its own results not build's results. |
After further review of the way clippy integrates with cargo (https://github.com/rust-lang/rust-clippy/blob/master/src/main.rs#L103-L111), it looks like clippy actually does need a way to ensure rustc will actually be invoked. This means cacheing the results of a rustc invocation within cargo and re-displaying them does not solve the clippy use case (clippy team, please let me know if I am misunderstanding here). I propose this PR can add a |
LGTM. The Cargo.toml isn't needed in the test (one is generated automatically). Also, maybe we should add --force-rebuild to I'd like to hear what @alexcrichton or @ehuss think, though, before landing this. |
Thanks, I'll remove this.
My primary concern is in the name of the arg. It only rebuilds the crate, but not its dependencies. It seems like that may not be intuitive if applied to Not to muddy the waters here I just want to make sure this is considered. |
I just tested this in a complex workspace of mine and there seems to be some bugs in how the There are 11 crates in this workspace, 2 are excluded so there should be 9 being forced to rebuild, but the only ones that I have seen consistently included are
|
The test failure is in the |
@Nemo157 For some reason I am not able to duplicate your issue under Given that, perhaps we want to reconsider whether the fix merges with this PR? For now I've pushed the fix in a commit to a different branch (9b3138c), but if everyone agrees I can merge that commit into this branch/PR. |
|
I think it's fine for clippy to use "unstable" features of Cargo, although perhaps not literally unstable features as they are today. In any case clippy, as an official tool now, should be fine to have support in Cargo which isn't intended for stable consumption elsewhere. (note that this interface, should it want to exist, would probably need to be designed rather than tacked on to something else existing). I also think that moving |
Yeah, cargo clippy is a very thin shim so it wouldn't change much.
…On Wed, Feb 20, 2019, 9:07 PM Alex Crichton ***@***.***> wrote:
I think it's fine for clippy to use "unstable" features of Cargo, although
perhaps not literally unstable features as they are today. In any case
clippy, as an official tool now, should be fine to have support in Cargo
which isn't intended for stable consumption elsewhere. (note that this
interface, should it want to exist, would probably need to be designed
rather than tacked on to something else existing).
I also think that moving cargo clippy into Cargo itself is fine so long
as cargo clippy doesn't get enough development to put a strain on this
repository.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6664 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABivSF3S4oQNyZAbt_8DWnyafvxQsw8mks5vPWvMgaJpZM4a7eRq>
.
|
Let me know if there needs to be any additional work here before merging. The test failure is in the |
CI seems happy with this—is there anything preventing it from being merged? |
I don't think adding a flag of this nature is ultimately the direction that we want to go. Caching shouldn't take very long to add once it is ready upstream. cargo-clippy is in the process of moving into this repo where we will have some more flexibility for the clippy side of things. I would like to propose the following: Merge this PR without any command-line flags and immediately stable. The intent would be that a caching implementation would remove this change in the near future. I'm not convinced that "running rustc again" is significantly painful. On cargo's source, for me with a warm cache, takes only a couple seconds. On servo, it takes about 7s. Clippy is a bit slower, but still reasonable. @rfcbot fcp merge If this fcp does not pass, I propose closing this PR instead and waiting for aforementioned items. Adding an unstable flag here will likely have the same timeframe as the caching implementation. |
Team member @ehuss has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I'm not sure about merging this. I have the experience (and maybe many others do) of habitually running commands in a sort of impulsive & subconscious way as I do my work. |
@rfcbot reviewed Note that while I do want to see the effect of this, I'd like to see the caching as well (both in the normal and clippy-enabled cases, and in an incremental way). I regularly do clippy/edit/clippy cycles and would like those to go as quickly as possible. |
Sounds like a reasonable concern. |
@ehuss @withoutboats I do think this is a great argument for caching. No good reason to rebuild just to display results. (And ideally, "fix one bug and recheck to get the rest" should go as quickly as possible and not take the same amount of time as the first check.) |
It has been 5 months since the last update, has there been any movement on getting caching of warnings?
Are these use-cases actually significantly affected by these changes? If you are editing the |
Clippy issue can be considered as fixed by #6759. Regular |
From my testing #6759 appears to essentially do what this change does and just recheck the targets every time without any caching of warnings (unless there's caching happening inside |
☔ The latest upstream changes (presumably #7350) made this pull request unmergeable. Please resolve the merge conflicts. |
🎉 |
This builds on the work from #5944, and pushed forward rust-lang/rust-clippy#2604. If ensures cargo check always does a rebuild.
The one thing I'm not sure of is whether this should be optional behind a command line flag? My initial thoughts are that most users would expect by default that
cargo check
always worked in this way (rebuilding and showing warnings every time it is ran), but that users runningcargo check
on a file system watcher might have some issues.