cargo fix: Call rustc fewer times.#13243
Merged
bors merged 2 commits intorust-lang:masterfrom Jan 3, 2024
Merged
Conversation
This adds a set of tests which validates various edge cases around how `cargo fix` works in terms of calling `rustc` multiple times. This uses a replacement of `rustc` so it doesn't depend on the behavior of rustc itself which is not always stable.
This changes `cargo fix` so that it keeps track of the output so that it doesn't need to run the final "show the output" step.
Collaborator
|
r? @epage (rustbot has picked a reviewer for you, use r? to override) |
Collaborator
|
Unknown labels: A-errors |
Contributor
|
Thanks! @bors r+ |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-actions |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 6, 2024
Update cargo 10 commits in add15366eaf3f3eb84717d3b8b71902ca36a7c84..2ce45605d9db521b5fd6c1211ce8de6055fdb24e 2024-01-02 03:24:42 +0000 to 2024-01-04 18:04:13 +0000 - feat(embedded): Add prefix-char frontmatter syntax support (rust-lang/cargo#13247) - Update dependency handlebars to v5 for mdman. (rust-lang/cargo#13249) - Deprecate rustc plugin support in cargo (rust-lang/cargo#13248) - feat(embedded): Add multiple experimental manifest syntaxes (rust-lang/cargo#13241) - chore: update auto labels (rust-lang/cargo#13244) - test: support publish package with a `public` field. (rust-lang/cargo#13245) - `cargo fix`: Call rustc fewer times. (rust-lang/cargo#13243) - chore: tracing be compat with rustc_log (rust-lang/cargo#13239) - chore(deps): update compatible (rust-lang/cargo#13227) - Contrib: Fix team HackMD links (rust-lang/cargo#13237) r? ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 fixso that it callsrustcone fewer times per target. The original code an extra step of callingrustcto display final diagnostics to the user. Part of the reason is that in the past, cargo did not always use JSON, and socargo fixwas forced to callrustcwith and without JSON. Now that cargo uses JSON all the time, that is not necessary. This avoids the final call torustcby 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 fixfails to apply some suggestion (either because the verification fails, orrustfixfails). Thecargo fixoutput 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
rustcreplacement 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
rustcand to avoid the final call.Fixes #13215