-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-json-outputArea: JSON message outputArea: JSON message outputC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Description
Describe the problem you are trying to solve
When integrating Cargo with an editor or IDE, it is common to use JSON to get structured messages from rustc
. However, Cargo's own messages (such as errors, warnings, etc.) are sent as plain text, making it difficult for the development environment to know how to display these messages.
Describe the solution you'd like
It would be nice if Cargo's messages were sent as JSON when --message-format=json
is used.
Notes
There are many decisions to be made on the behavior and exact structure to use.
- Is it OK to simply change Cargo to start sending JSON with
--message-format=json
? That could break or disrupt tools, though I'm not sure how likely that is, or what the consequences would be. Cargo could include something like rustc's--json
flag to configure JSON behavior, but it would be nice to avoid if possible to keep things simple. - Should Cargo re-use rustc's
"compiler-message"
structure for warnings and errors, or should it add a new one? It might be difficult to shoe-horn Cargo's format (which uses a stack of causes) to rustc's format. The drawback of using a separate structure is that then there would need to be multiple ways to handle "messages". - What other activities and messages should be JSON messages? See Add a term option to configure the progress bar #8165 (comment) for some examples. Cargo has many different things it prints (status messages, "downloading", etc.), and there are quite a few action points ("build started", "unit started", "unit finished", etc.) that could be useful to have as JSON. (
cargo … --message-format json
should tell you when it starts compiling a cate. #12864) - Should Cargo intercept non-JSON output from rustc and wrap it in JSON (Proc macros can cause non-json output in stdout despite message-format=json #8179)?
- Should we include
build.rs
warnings? What about-vv
output ofbuild.rs
(Build script warnings don't respect--message-format=json
. #14246)?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-json-outputArea: JSON message outputArea: JSON message outputC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.