cargo fix
: Call rustc fewer times.
#13243
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an improvement of
cargo fix
so that it callsrustc
one fewer times per target. The original code an extra step of callingrustc
to display final diagnostics to the user. Part of the reason is that in the past, cargo did not always use JSON, and socargo fix
was forced to callrustc
with and without JSON. Now that cargo uses JSON all the time, that is not necessary. This avoids the final call torustc
by remembering the original output fromrustc
.This needs to keep track of both the first and last output from
rustc
. This is to handle the situation wherecargo fix
fails to apply some suggestion (either because the verification fails, orrustfix
fails). Thecargo fix
output includes both the error, and the original diagnostics before the error.The first commit is a little test framework to exercise the various edge cases around how fix works. The comments should explain how it works, but it essentially has a
rustc
replacement that emits various different diagnostics and counts how often it is called.The subsequent commit includes the change to keep track of the output from
rustc
and to avoid the final call.Fixes #13215