Unify cargo and rustc's error reporting#9655
Merged
bors merged 2 commits intorust-lang:masterfrom Jul 7, 2021
Merged
Conversation
Here is a typical error seen by users of Cargo: ``` error[E0601]: `main` function not found in crate `wrong` | = note: consider adding a `main` function to `src/main.rs` error: aborting due to previous error For more information about this error, try `rustc --explain E0601`. error: could not compile `wrong` To learn more, run the command again with --verbose. ``` The `--verbose` output is not particularly helpful in this case. The error is unrelated to what cargo is doing, and passing `--verbose` will not give useful information about how to proceed. Additionally, it's unclear that `--verbose` is referring to the cargo command and not rustc; this is especially true when cargo is wrapped by another build system (such as Meson, x.py, or Make). This omits the "run the command again with --verbose" output. --verbose is still shown in `cargo build --help`, but it's not singled out above all the other options.
|
(rust-highfive has picked a reviewer for you, use r? to override) |
Member
Author
|
The original example from rust-lang/rust#86854 now looks like this: |
e1404ae to
0e7af00
Compare
ehuss
reviewed
Jul 6, 2021
Contributor
ehuss
left a comment
There was a problem hiding this comment.
Looks good, I think this is a great improvement.
This works by introspecting rustc's error output, using the JSON format to determine whether it's a warning or error, then skipping it altogether if it's a summary of the diagnostics printed. Before: ``` src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong` src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object error: aborting due to 2 previous errors; 1 warning emitted error: could not compile `wrong` ``` After: ``` $ cargo check --message-format short src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong` src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object error: could not compile `wrong` due to 2 previous errors; 1 warning emitted ```
Contributor
|
Thanks! @bors r+ |
Contributor
|
📌 Commit 9c7cc54 has been approved by |
Contributor
Contributor
|
☀️ Test successful - checks-actions |
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jul 15, 2021
Update cargo 13 commits in 3ebb5f15a940810f250b68821149387af583a79e..66a6737a0c9f3a974af2dd032a65d3e409c77aac 2021-07-02 20:35:38 +0000 to 2021-07-14 20:54:28 +0000 - Add format option to `cargo tree` to print the lib_name (rust-lang/cargo#9663) - Prefer patched versions of dependencies (rust-lang/cargo#9639) - When a dependency does not have a version, git or path, fails directly (rust-lang/cargo#9686) - Spot the crate typo easily (rust-lang/cargo#9665) - remove unnecessary 'collect' (rust-lang/cargo#9616) - Make it easier to run testsuite with a custom toolchain. (rust-lang/cargo#9679) - Serialize `cargo fix` (rust-lang/cargo#9677) - Don't recommend filing issues on rust-lang/cargo for Cargo.toml errors. (rust-lang/cargo#9658) - Update nightly failure notification. (rust-lang/cargo#9657) - Update Windows env uppercase key check. (rust-lang/cargo#9654) - Unignore fix_edition_2021. (rust-lang/cargo#9662) - Warning when using features in patch (rust-lang/cargo#9666) - Unify cargo and rustc's error reporting (rust-lang/cargo#9655)
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jul 15, 2021
Update cargo 13 commits in 3ebb5f15a940810f250b68821149387af583a79e..66a6737a0c9f3a974af2dd032a65d3e409c77aac 2021-07-02 20:35:38 +0000 to 2021-07-14 20:54:28 +0000 - Add format option to `cargo tree` to print the lib_name (rust-lang/cargo#9663) - Prefer patched versions of dependencies (rust-lang/cargo#9639) - When a dependency does not have a version, git or path, fails directly (rust-lang/cargo#9686) - Spot the crate typo easily (rust-lang/cargo#9665) - remove unnecessary 'collect' (rust-lang/cargo#9616) - Make it easier to run testsuite with a custom toolchain. (rust-lang/cargo#9679) - Serialize `cargo fix` (rust-lang/cargo#9677) - Don't recommend filing issues on rust-lang/cargo for Cargo.toml errors. (rust-lang/cargo#9658) - Update nightly failure notification. (rust-lang/cargo#9657) - Update Windows env uppercase key check. (rust-lang/cargo#9654) - Unignore fix_edition_2021. (rust-lang/cargo#9662) - Warning when using features in patch (rust-lang/cargo#9666) - Unify cargo and rustc's error reporting (rust-lang/cargo#9655)
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jul 15, 2021
Update cargo 13 commits in 3ebb5f15a940810f250b68821149387af583a79e..66a6737a0c9f3a974af2dd032a65d3e409c77aac 2021-07-02 20:35:38 +0000 to 2021-07-14 20:54:28 +0000 - Add format option to `cargo tree` to print the lib_name (rust-lang/cargo#9663) - Prefer patched versions of dependencies (rust-lang/cargo#9639) - When a dependency does not have a version, git or path, fails directly (rust-lang/cargo#9686) - Spot the crate typo easily (rust-lang/cargo#9665) - remove unnecessary 'collect' (rust-lang/cargo#9616) - Make it easier to run testsuite with a custom toolchain. (rust-lang/cargo#9679) - Serialize `cargo fix` (rust-lang/cargo#9677) - Don't recommend filing issues on rust-lang/cargo for Cargo.toml errors. (rust-lang/cargo#9658) - Update nightly failure notification. (rust-lang/cargo#9657) - Update Windows env uppercase key check. (rust-lang/cargo#9654) - Unignore fix_edition_2021. (rust-lang/cargo#9662) - Warning when using features in patch (rust-lang/cargo#9666) - Unify cargo and rustc's error reporting (rust-lang/cargo#9655)
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.
Fixes rust-lang/rust#86854.
Don't print "run the command again with --verbose"
Here is a typical error seen by users of Cargo:
The
--verboseoutput is not particularly helpful in this case. Theerror is unrelated to what cargo is doing, and passing
--verbosewillnot give useful information about how to proceed. Additionally, it's
unclear that
--verboseis referring to the cargo command and notrustc; this is especially true when cargo is wrapped by another build
system (such as Meson, x.py, or Make).
This omits the "run the command again with --verbose" output. --verbose
is still shown in
cargo build --help, but it's not singled out aboveall the other options.
Combine rustc and cargo's diagnostic summaries
This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.
Before:
After: