There's quite a lot of manual boilerplate in rustc and cargo required to support every option.
In rustc (using this as an example):
- It needs a
sym
defined for the option name, and each of its values, and create a function listing all valid symbols. - It needs to define an internal
enum
orstruct
for its parsed value - It needs to define a parser converting from CLI string flag to the internal value
- It needs error text added for the CLI parser, because the parser returns
false
instead ofErr
- It needs help text added to the list of CLI flags
- It needs a
cfg(option)
defined - It needs UI tests for the new
cfg(option)
and each of its values - It needs to add the
cfg
to the list of disallowed usercfg
s - It needs to add the
cfg
to the test of the list of disallowedcfg
- It needs to bless the output of check-cfg tests and a few others
- It needs to add the
cfg
to the list of allowedcfg
s inCheckCfg
- It needs check-cfg documentation updated
- It needs a help chapter in the unstable book
- It needs to be added to the list of unstable flags
- It needs to be added to the default session configuration, gated on nightly options
- It needs to be added to the test of options tracked by the session
- It may need
#![feature(option)]
added to tests and libraries
Then in Cargo:
- It needs to be added to
util::toml
structs for the appropriateCargo.toml
section - It usually needs a custom struct with a
TryFrom
orserde::Deserialize
implementation to parse the value from multiple TOML representations. - It needs to be added to the list of nightly Cargo features
- It needs help text and parser added for the nightly Cargo feature flags
- It needs nightly-only tests checking the TOML parsing and the
-Z
flag - It may need additional logic and tests for passing the option down to rustdoc
- It needs to be added to internal structs representing options
- It needs to be added to the hash tracking build options
- It needs to be added to code serializing
rustc
flags, and update countless Cargo text output tests that expose the flags - It needs to be added to functions constructing default internal options and functions converting from TOML-deserialized structs
- It may need to be added to
config.toml
representation, and have code added for merging of options, along with tests for parsing TOML as well as test automagic mapping from env vars toconfig.toml
options - It may need to be exposed as an env var in build scripts, along with bespoke tests for this
- It needs to be added to Cargo's option reference.
and then when stabilizing:
- The nightly-only option gates need to be deleted.
- The lists of unstable options need to be updated to make them stable, separately for rustc and Cargo.
- Tests need to be updated to test the stable version of the CLI flags.
- Cargo output tests need to be updated to allow the stable flag.
That's A LOT, and this doesn't include any of the actual functionality behind the flag! These steps are just for making a flag exist, and get passed between Cargo and rustc.
A few steps like definition of the flag, its syntax, and its documentation are obviously necessary. But a lot of steps around parsing, serializing, and testing of the parsers and serializers seems to needlessly require bespoke code and bespoke tests.