Skip to content

Conversation

@matthewhughes934
Copy link

Previously on a stable build (json is only supported in nightly builds):

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

With this change:

$ CFG_RELEASE_CHANNEL=stable cargo make bin-build
$ PATH="./target/debug:$PATH" cargo fmt --message-format json
--message-format json is only supported in nightly builds
This utility formats all bin and lib files of the current crate using rustfmt.
<-- SNIP: the rest of the usage follows -->

This behaviour is similar to how args to --emit are handled in rustfmt.

This change also drops displaying json as an option to --message-format on stable builds:

$ PATH="./target/debug:$PATH" cargo fmt --help | grep --max-count 1 --after-context 1 message-format
    --message-format <message-format>
        Specify message-format: short|human

This required rewriting the check for nightly builds (copying from the one in src/release_channel.rs) to be const so I could rewrite the --message-format flag's help string.

Issue: #6752

Previously on a stable build (`json` is only supported in `nightly`
builds):

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

With this change:

    $ CFG_RELEASE_CHANNEL=stable cargo make bin-build
    $ PATH="./target/debug:$PATH" cargo fmt --message-format json
    --message-format json is only supported in nightly builds
    This utility formats all bin and lib files of the current crate using rustfmt.
    <-- SNIP: the rest of the usage follows -->

This behaviour is similar to how args to `--emit` are handled in
`rustfmt`.

This change also drops displaying `json` as an option to
`--message-format` on stable builds:

    $ PATH="./target/debug:$PATH" cargo fmt --help | grep --max-count 1 --after-context 1 message-format
        --message-format <message-format>
            Specify message-format: short|human

This required rewriting the check for nightly builds (copying from the
one in `src/release_channel.rs`) to be `const` so I could rewrite the
`--message-format` flag's help string.

Issue: rust-lang#6752
@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants