Reviewer · Configurations
Gate unstable configuration consistently
New configurable behavior (CLI options, manifest keys, and any lints/warnings they trigger) must be introduced through the standard `-Z` unstable mechanism, and that gating must be applied consistently everywhere the feature has an effect.
New configurable behavior (CLI options, manifest keys, and any lints/warnings they trigger) must be introduced through the standard -Z unstable mechanism, and that gating must be applied consistently everywhere the feature has an effect.
- Prefer extending an existing config/option (e.g. folding a new setting into
build.build-stdrather than inventing a parallel option) unless the new behavior is semantically distinct enough to warrant its own-Zflag; don’t add a new unstable flag just because gating via the generalunstable-optionsswitch feels awkward. - Use the shared helpers for erroring on stable (e.g.
cli_unstable().fail_if_stable_opt(...)) instead of hand-rolled checks, so error messages and behavior stay uniform across options. - When a feature produces secondary effects such as a new lint or warning (e.g.
unexpected_cfgs), the samefeature_gatemust be attached to that effect too — don’t gate only the data acquisition (like fetchingcheck-cfgs) while leaving the lint itself ungated, or it will leak onto stable. - Removing a
-Zflag can be done directly (followingrustc’s precedent) without extra process, as long as it isn’t a stabilization. - When computing defaults based on release channel (e.g. enabling something only on
nightly/dev), account forRUSTC_BOOTSTRAP=1, which makes the channel appear asdeveven on stable/beta toolchains. Use a canonical channel check (e.g.release_channel == Some("nightly")) or explicitly exclude the bootstrap-override case so unstable defaults don’t silently activate for users who only setRUSTC_BOOTSTRAPto unlock a specific unstable feature.
Example of preferring the shared helper:
if lockfile_path.is_some() {
gctx.cli_unstable().fail_if_stable_opt("--lockfile-path", 5707)?;
}
instead of a manual if !gctx.cli_unstable().unstable_options { bail!(...) } check.