-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Provide Cargo messages as JSON messages #8283
Copy link
Copy link
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.
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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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.Similarly, some CI systems may want output formatted to match their logging needs (#6751).
Describe the solution you'd like
It would be nice if Cargo's messages were sent as JSON when
--message-format=jsonis used.Notes
There are many decisions to be made on the behavior and exact structure to use.
--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--jsonflag to configure JSON behavior, but it would be nice to avoid if possible to keep things simple."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".cargo … --message-format jsonshould tell you when it starts compiling a cate. #12864)build.rswarnings? What about-vvoutput ofbuild.rs(Build script warnings don't respect--message-format=json. #14246)?