rust-lang/rustfmt

Unable to use `--message-format=json`

JP-Ellis opened this issue · 2 comments

I recently found the undocumented --message-format option from #3752; however, trying to use it results in the following error message:

$ cargo fmt --message-format=json
Invalid value for `--emit` - using an unstable value without `--unstable-features`

so as the error message suggests, I tried enabling unstable features, but this can only be done on the nightly branch.

Is there a tracking issue or eta as to when this will land in the stable channel?

the undocumented --message-format option

The CLI help text for cargo fmt includes info on the various flags/options it accepts, including --message-format. AFAIK the cargo fmt specific flags/opts are not explicitly documented anywhere else. However, if they are but are missing --message-format then that should be remedied.

Is there a tracking issue or eta as to when this will land in the stable channel?

Good question. The --message-format option to cargo fmt is translated into the corresponding --emit mode for rustfmt, so the underlying driver of the nightly requirement for --message-format json is that the json emitter is still technically nightly-only: https://github.com/rust-lang/rustfmt#tips (scroll down to the emit mode table).

I'm not aware of any tracking issue for the stabilization of the json emit mode, but IMO both the json and checkstyle emitters are ready for stabilization.

Oops, sorry I'm wrong about the stabilization readiness. I forgot about an issue that can occur with the json emitter (as well as the checkstyle emitter) that should be resolved first, now detailed in #3952

I'll open a PR with a fix for #3952 within the next day or so, after which I believe the json emitter (and thus cargo fmt's --message-format json option) will be ready for stabilization.