How stable is cargo's message-format=json?


Specifically, I’m interested in the stdout of cargo test --no-run --message-format=json.

I’m interested in extracting the list of test binaries without linking against cargo or scraping the human output. The “compiler errors and warnings, produced artifacts, [and] results of the build scripts” that the json message format provides contains the information that I want, but what about the format can I expect to remain the same? (Conversely, what about the output is free to change in the future?)


It is stable. We most likely will add new fields to the json object, and will add new types of json messages though. In the unlikely event that we’ll have for some reason to make a backwards-incompatible change, we’ll probably add --message-format=json-v2.

FWIW, these events are used by IntelliJ Rust when launching debugger:

Beware of kind and crate_types fields from Target: they are super confusing at the moment precisely because of backwards compatibility :slight_smile: