Skip to content

cargo fmt --message-format json error is hard to understand (on stable). #6752

@t-moe

Description

@t-moe

Problem

cargo fmt --message-format json shows an error that is hard to understand.

> cd /tmp && cargo new foo && cd foo/
> cargo fmt  --message-format json
Invalid value for `--emit` - using an unstable value without `--unstable-features`

Running the command in verbose mode reveals the invocation:

rustfmt --edition 2024 --emit json /tmp/foo/src/main.rs

cargo +nightly fmt --message-format json works as expected.

Note that the help output of cargo fmt --help explicitly lists JSON as an option (on stable).

Version

>  cargo version --verbose
cargo 1.90.0 (840b83a10 2025-07-30)
release: 1.90.0
commit-hash: 840b83a10fb0e039a83f4d70ad032892c287570a
commit-date: 2025-07-30
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.14.1-DEV (sys:0.4.82+curl-8.14.1 vendored ssl:OpenSSL/3.5.0)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Ubuntu 24.4.0 (noble) [64-bit]
> rustfmt --version
rustfmt 1.8.0-stable (1159e78c47 2025-09-14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cliArea: command-line interfaceA-diagnosticsArea: diagnostics, of rustfmt itself or cargo-fmtC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions