-
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
Fix --message-format JSON
when rustc emits non-JSON warnings
#3410
Fix --message-format JSON
when rustc emits non-JSON warnings
#3410
Conversation
The `--message-format JSON` flag parses all the stderr output of rustc to JSON, but rustc can emit non-JSON lines to stderr (e.g., for warning about the unstable `-Z` flag on the stable channel), causing cargo to fail reporting compilation errors when using `--message-format JSON`. This commit adds a check to look for lines beginning with `{` to only parse these lines as JSON. Other lines from rustc are forwarded to the stderr of cargo. Fixes rust-lang#3390.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (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. |
@matklad To forward the output to stderr, using
I used Please let me know if I should change it (and hint at the correct way to do it, since I haven't looked much at dealing with threads in Rust). |
This looks good to me, thanks! Could you also add a test for this? |
@alexcrichton Done. I've added to make sure that JSON errors are emitted, and that stderr is forwarded. The test is skipped with a nightly rustc, since the warning for |
397ac0d
to
3e32503
Compare
@bors: r+ Thanks! |
📌 Commit 3e32503 has been approved by |
…alexcrichton Fix `--message-format JSON` when rustc emits non-JSON warnings The `--message-format JSON` flag parses all the stderr output of rustc to JSON, but rustc can emit non-JSON lines to stderr (e.g., for warning about the unstable `-Z` flag on the stable channel), causing cargo to fail reporting compilation errors when using `--message-format JSON`. This commit adds a check to look for lines beginning with `{` to only parse these lines as JSON. Other lines from rustc are forwarded to the stderr of cargo. Fixes #3390.
💔 Test failed - status-appveyor |
Oh that looks like rust-lang/rust#38177 which was fixed in rust-lang/rust#38357 which should be in the next nightly, I'll r+ then. |
@bors: retry |
…alexcrichton Fix `--message-format JSON` when rustc emits non-JSON warnings The `--message-format JSON` flag parses all the stderr output of rustc to JSON, but rustc can emit non-JSON lines to stderr (e.g., for warning about the unstable `-Z` flag on the stable channel), causing cargo to fail reporting compilation errors when using `--message-format JSON`. This commit adds a check to look for lines beginning with `{` to only parse these lines as JSON. Other lines from rustc are forwarded to the stderr of cargo. Fixes #3390.
☀️ Test successful - status-appveyor, status-travis |
The
--message-format JSON
flag parses all the stderr output of rustc to JSON,but rustc can emit non-JSON lines to stderr (e.g., for warning about the
unstable
-Z
flag on the stable channel), causing cargo to fail reportingcompilation errors when using
--message-format JSON
.This commit adds a check to look for lines beginning with
{
to only parsethese lines as JSON. Other lines from rustc are forwarded to the stderr of
cargo.
Fixes #3390.