68
68
//! get an instance of `CliUnstable` and check if the option has been
69
69
//! enabled on the `CliUnstable` instance. Nightly gating is already
70
70
//! handled, so no need to worry about that.
71
- //! 4. Update the `-Z help` documentation in the `main` function.
72
71
//!
73
72
//! ## Stabilization
74
73
//!
83
82
//! 2. `-Z unstable-options`: Find the call to `fail_if_stable_opt` and
84
83
//! remove it. Be sure to update the man pages if necessary.
85
84
//! 3. `-Z` flag: Change the parsing code in [`CliUnstable::add`] to call
86
- //! `stabilized_warn` or `stabilized_err`. Remove it from the `-Z help`
87
- //! docs in the `main` function . Remove the `(unstable)` note in the
88
- //! clap help text if necessary.
85
+ //! `stabilized_warn` or `stabilized_err` and remove the field from
86
+ //! `CliUnstable . Remove the `(unstable)` note in the clap help text if
87
+ //! necessary.
89
88
//! 2. Remove `masquerade_as_nightly_cargo` from any tests, and remove
90
89
//! `cargo-features` from `Cargo.toml` test files if any.
91
90
//! 3. Remove the docs from unstable.md and update the redirect at the bottom
@@ -105,6 +104,7 @@ use crate::util::errors::CargoResult;
105
104
use crate :: util:: { indented_lines, iter_join} ;
106
105
use crate :: Config ;
107
106
107
+ pub const HIDDEN : & str = "" ;
108
108
pub const SEE_CHANNELS : & str =
109
109
"See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \
110
110
about Rust release channels.";
@@ -538,51 +538,73 @@ impl Features {
538
538
}
539
539
}
540
540
541
- /// A parsed representation of all unstable flags that Cargo accepts.
542
- ///
543
- /// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for
544
- /// gating unstable functionality to Cargo. These flags are only available on
545
- /// the nightly channel of Cargo.
546
- #[ derive( Default , Debug , Deserialize ) ]
547
- #[ serde( default , rename_all = "kebab-case" ) ]
548
- pub struct CliUnstable {
541
+ macro_rules! unstable_cli_options {
542
+ (
543
+ $(
544
+ $( #[ $meta: meta] ) ?
545
+ $element: ident: $ty: ty = ( $help: expr )
546
+ ) ,*
547
+ ) => {
548
+ /// A parsed representation of all unstable flags that Cargo accepts.
549
+ ///
550
+ /// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for
551
+ /// gating unstable functionality to Cargo. These flags are only available on
552
+ /// the nightly channel of Cargo.
553
+ #[ derive( Default , Debug , Deserialize ) ]
554
+ #[ serde( default , rename_all = "kebab-case" ) ]
555
+ pub struct CliUnstable {
556
+ $(
557
+ $( #[ $meta] ) ?
558
+ pub $element: $ty
559
+ ) ,*
560
+ }
561
+ impl CliUnstable {
562
+ pub fn help( ) -> Vec <( & ' static str , & ' static str ) > {
563
+ let fields = vec![ $( ( stringify!( $element) , $help) ) ,* ] ;
564
+ fields
565
+ }
566
+ }
567
+ }
568
+ }
569
+
570
+ unstable_cli_options ! (
549
571
// Permanently unstable features:
550
- pub allow_features : Option < BTreeSet < String > > ,
551
- pub print_im_a_teapot : bool ,
572
+ allow_features: Option <BTreeSet <String >> = ( "Allow *only* the listed unstable features" ) ,
573
+ print_im_a_teapot: bool = ( HIDDEN ) ,
552
574
553
575
// All other unstable features.
554
576
// Please keep this list lexiographically ordered.
555
- pub advanced_env : bool ,
556
- pub avoid_dev_deps : bool ,
557
- pub binary_dep_depinfo : bool ,
577
+ advanced_env: bool = ( HIDDEN ) ,
578
+ avoid_dev_deps: bool = ( "Avoid installing dev-dependencies if possible" ) ,
579
+ binary_dep_depinfo: bool = ( "Track changes to dependency artifacts" ) ,
558
580
#[ serde( deserialize_with = "deserialize_build_std" ) ]
559
- pub build_std : Option < Vec < String > > ,
560
- pub build_std_features : Option < Vec < String > > ,
561
- pub config_include : bool ,
562
- pub configurable_env : bool ,
563
- pub credential_process : bool ,
564
- pub doctest_in_workspace : bool ,
565
- pub doctest_xcompile : bool ,
566
- pub dual_proc_macros : bool ,
567
- pub enable_future_incompat_feature : bool ,
568
- pub extra_link_arg : bool ,
569
- pub features : Option < Vec < String > > ,
570
- pub jobserver_per_rustc : bool ,
571
- pub minimal_versions : bool ,
572
- pub mtime_on_use : bool ,
573
- pub multitarget : bool ,
574
- pub named_profiles : bool ,
575
- pub namespaced_features : bool ,
576
- pub no_index_update : bool ,
577
- pub panic_abort_tests : bool ,
578
- pub patch_in_config : bool ,
579
- pub rustdoc_map : bool ,
580
- pub separate_nightlies : bool ,
581
- pub terminal_width : Option < Option < usize > > ,
582
- pub timings : Option < Vec < String > > ,
583
- pub unstable_options : bool ,
584
- pub weak_dep_features : bool ,
585
- }
581
+ build_std: Option <Vec <String >> = ( "Enable Cargo to compile the standard library itself as part of a crate graph compilation" ) ,
582
+ build_std_features: Option <Vec <String >> = ( "Configure features enabled for the standard library itself when building the standard library" ) ,
583
+ config_include: bool = ( "Enable the `include` key in config files" ) ,
584
+ configurable_env: bool = ( "Enable the [env] section in the .cargo/config.toml file" ) ,
585
+ credential_process: bool = ( "Add a config setting to fetch registry authentication tokens by calling an external process" ) ,
586
+ doctest_in_workspace: bool = ( "Compile doctests with paths relative to the workspace root" ) ,
587
+ doctest_xcompile: bool = ( "Compile and run doctests for non-host target using runner config" ) ,
588
+ dual_proc_macros: bool = ( "Build proc-macros for both the host and the target" ) ,
589
+ future_incompat_report : bool = ( "Enable creation of a future-incompat report for all dependencies" ) ,
590
+ extra_link_arg: bool = ( "Allow `cargo:rustc-link-arg` in build scripts" ) ,
591
+ features: Option <Vec <String >> = ( HIDDEN ) ,
592
+ jobserver_per_rustc: bool = ( HIDDEN ) ,
593
+ minimal_versions: bool = ( "Resolve minimal dependency versions instead of maximum" ) ,
594
+ mtime_on_use: bool = ( "Configure Cargo to update the mtime of used files" ) ,
595
+ multitarget: bool = ( "Allow passing multiple `--target` flags to the cargo subcommand selected" ) ,
596
+ named_profiles: bool = ( "Allow defining custom profiles" ) ,
597
+ namespaced_features: bool = ( "Allow features with `dep:` prefix" ) ,
598
+ no_index_update: bool = ( "Do not update the registry index even if the cache is outdated" ) ,
599
+ panic_abort_tests: bool = ( "Enable support to run tests with -Cpanic=abort" ) ,
600
+ patch_in_config: bool = ( "Allow `[patch]` sections in .cargo/config.toml files" ) ,
601
+ rustdoc_map: bool = ( "Allow passing external documentation mappings to rustdoc" ) ,
602
+ separate_nightlies: bool = ( HIDDEN ) ,
603
+ terminal_width: Option <Option <usize >> = ( "Provide a terminal width to rustc for error truncation" ) ,
604
+ timings: Option <Vec <String >> = ( "Display concurrency information" ) ,
605
+ unstable_options: bool = ( "Allow the usage of unstable options" ) ,
606
+ weak_dep_features: bool = ( "Allow `dep_name?/feature` feature syntax" )
607
+ ) ;
586
608
587
609
const STABILIZED_COMPILE_PROGRESS : & str = "The progress bar is now always \
588
610
enabled when used on an interactive console.\n \
@@ -798,7 +820,7 @@ impl CliUnstable {
798
820
"config-profile" => stabilized_warn ( k, "1.43" , STABILIZED_CONFIG_PROFILE ) ,
799
821
"crate-versions" => stabilized_warn ( k, "1.47" , STABILIZED_CRATE_VERSIONS ) ,
800
822
"package-features" => stabilized_warn ( k, "1.51" , STABILIZED_PACKAGE_FEATURES ) ,
801
- "future-incompat-report" => self . enable_future_incompat_feature = parse_empty ( k, v) ?,
823
+ "future-incompat-report" => self . future_incompat_report = parse_empty ( k, v) ?,
802
824
_ => bail ! ( "unknown `-Z` flag specified: {}" , k) ,
803
825
}
804
826
0 commit comments