Commit 0969c6d
committed
Improve error for nightly-only '--message-format' args
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: #67521 parent 4b620cd commit 0969c6d
2 files changed
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
| |||
54 | 67 | | |
55 | 68 | | |
56 | 69 | | |
57 | | - | |
58 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
| |||
186 | 202 | | |
187 | 203 | | |
188 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
189 | 210 | | |
190 | 211 | | |
191 | 212 | | |
| |||
202 | 223 | | |
203 | 224 | | |
204 | 225 | | |
205 | | - | |
| 226 | + | |
| 227 | + | |
206 | 228 | | |
207 | 229 | | |
208 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | | - | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
13 | 28 | | |
14 | 29 | | |
15 | 30 | | |
| |||
21 | 36 | | |
22 | 37 | | |
23 | 38 | | |
| 39 | + | |
24 | 40 | | |
25 | 41 | | |
26 | 42 | | |
| |||
32 | 48 | | |
33 | 49 | | |
34 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
35 | 63 | | |
36 | 64 | | |
37 | 65 | | |
| |||
0 commit comments