Skip to content

Commit 3da1443

Browse files
committed
Auto merge of #4433 - alexcrichton:unstable-features, r=matklad
Add infrastructure for nightly features and flags This PR starts adding infrastructure in Cargo for nightly features and nightly flags. The current design looks like: * There's a new `package.cargo-features` manifest key which accepts an array of strings. This array of strings is the list of enabled Cargo features for that crate. * A new suite of flags behind `-Z`, like the compiler, are accepted on the command line for all commands. * Features and unstable flags in Cargo are required to be used on Cargo's nightly channel, which is the same as Rust's nightly channel. * Features and unstable flags cannot be used on the stable/beta channels of Rust/Cargo. * Crates which enable features in their manifest are disallowed from being published to crates.io The motivation behind this support is unblock a number of efforts in Cargo by allowing them to safely get implemented behind a nightly feature gate. Once behind a feature gate they can iterate in-tree without having to worry about "insta stability" and we can also get valuable usage feedback about upstream users. Closes #4409
2 parents 69fa59a + f26fc37 commit 3da1443

37 files changed

+753
-36
lines changed

src/bin/bench.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub struct Options {
3535
arg_args: Vec<String>,
3636
flag_all: bool,
3737
flag_exclude: Vec<String>,
38+
#[serde(rename = "flag_Z")]
39+
flag_z: Vec<String>,
3840
}
3941

4042
pub const USAGE: &'static str = "
@@ -72,6 +74,7 @@ Options:
7274
--no-fail-fast Run all benchmarks regardless of failure
7375
--frozen Require Cargo.lock and cache are up to date
7476
--locked Require Cargo.lock is up to date
77+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
7578
7679
All of the trailing arguments are passed to the benchmark binaries generated
7780
for filtering benchmarks and generally providing options configuring how they
@@ -99,7 +102,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
99102
options.flag_quiet,
100103
&options.flag_color,
101104
options.flag_frozen,
102-
options.flag_locked)?;
105+
options.flag_locked,
106+
&options.flag_z)?;
103107

104108
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
105109
let ws = Workspace::new(&root, config)?;

src/bin/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ pub struct Options {
3333
flag_frozen: bool,
3434
flag_all: bool,
3535
flag_exclude: Vec<String>,
36+
#[serde(rename = "flag_Z")]
37+
flag_z: Vec<String>,
3638
}
3739

3840
pub const USAGE: &'static str = "
@@ -69,6 +71,7 @@ Options:
6971
--message-format FMT Error format: human, json [default: human]
7072
--frozen Require Cargo.lock and cache are up to date
7173
--locked Require Cargo.lock is up to date
74+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
7275
7376
If the --package argument is given, then SPEC is a package id specification
7477
which indicates which package should be built. If it is not given, then the
@@ -91,7 +94,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
9194
options.flag_quiet,
9295
&options.flag_color,
9396
options.flag_frozen,
94-
options.flag_locked)?;
97+
options.flag_locked,
98+
&options.flag_z)?;
9599

96100
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
97101
let ws = Workspace::new(&root, config)?;

src/bin/cargo.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub struct Flags {
3131
arg_args: Vec<String>,
3232
flag_locked: bool,
3333
flag_frozen: bool,
34+
#[serde(rename = "flag_Z")]
35+
flag_z: Vec<String>,
3436
}
3537

3638
const USAGE: &'static str = "
@@ -50,6 +52,7 @@ Options:
5052
--color WHEN Coloring: auto, always, never
5153
--frozen Require Cargo.lock and cache are up to date
5254
--locked Require Cargo.lock is up to date
55+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
5356
5457
Some common cargo commands are (see all commands with --list):
5558
build Compile the current project
@@ -149,7 +152,8 @@ fn execute(flags: Flags, config: &Config) -> CliResult {
149152
flags.flag_quiet,
150153
&flags.flag_color,
151154
flags.flag_frozen,
152-
flags.flag_locked)?;
155+
flags.flag_locked,
156+
&flags.flag_z)?;
153157

154158
init_git_transports(config);
155159
let _token = cargo::util::job::setup();

src/bin/check.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Options:
3939
--message-format FMT Error format: human, json [default: human]
4040
--frozen Require Cargo.lock and cache are up to date
4141
--locked Require Cargo.lock is up to date
42+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
4243
4344
If the --package argument is given, then SPEC is a package id specification
4445
which indicates which package should be built. If it is not given, then the
@@ -78,6 +79,8 @@ pub struct Options {
7879
flag_frozen: bool,
7980
flag_all: bool,
8081
flag_exclude: Vec<String>,
82+
#[serde(rename = "flag_Z")]
83+
flag_z: Vec<String>,
8184
}
8285

8386
pub fn execute(options: Options, config: &Config) -> CliResult {
@@ -88,7 +91,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
8891
options.flag_quiet,
8992
&options.flag_color,
9093
options.flag_frozen,
91-
options.flag_locked)?;
94+
options.flag_locked,
95+
&options.flag_z)?;
9296

9397
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
9498
let ws = Workspace::new(&root, config)?;

src/bin/clean.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub struct Options {
1616
flag_release: bool,
1717
flag_frozen: bool,
1818
flag_locked: bool,
19+
#[serde(rename = "flag_Z")]
20+
flag_z: Vec<String>,
1921
}
2022

2123
pub const USAGE: &'static str = "
@@ -35,6 +37,7 @@ Options:
3537
--color WHEN Coloring: auto, always, never
3638
--frozen Require Cargo.lock and cache are up to date
3739
--locked Require Cargo.lock is up to date
40+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
3841
3942
If the --package argument is given, then SPEC is a package id specification
4043
which indicates which package's artifacts should be cleaned out. If it is not
@@ -48,7 +51,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
4851
options.flag_quiet,
4952
&options.flag_color,
5053
options.flag_frozen,
51-
options.flag_locked)?;
54+
options.flag_locked,
55+
&options.flag_z)?;
5256

5357
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
5458
let opts = ops::CleanOptions {

src/bin/doc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub struct Options {
2727
flag_frozen: bool,
2828
flag_locked: bool,
2929
flag_all: bool,
30+
#[serde(rename = "flag_Z")]
31+
flag_z: Vec<String>,
3032
}
3133

3234
pub const USAGE: &'static str = "
@@ -57,6 +59,7 @@ Options:
5759
--message-format FMT Error format: human, json [default: human]
5860
--frozen Require Cargo.lock and cache are up to date
5961
--locked Require Cargo.lock is up to date
62+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
6063
6164
By default the documentation for the local package and all dependencies is
6265
built. The output is all placed in `target/doc` in rustdoc's usual format.
@@ -78,7 +81,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
7881
options.flag_quiet,
7982
&options.flag_color,
8083
options.flag_frozen,
81-
options.flag_locked)?;
84+
options.flag_locked,
85+
&options.flag_z)?;
8286

8387
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
8488
let ws = Workspace::new(&root, config)?;

src/bin/fetch.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub struct Options {
1111
flag_color: Option<String>,
1212
flag_frozen: bool,
1313
flag_locked: bool,
14+
#[serde(rename = "flag_Z")]
15+
flag_z: Vec<String>,
1416
}
1517

1618
pub const USAGE: &'static str = "
@@ -27,6 +29,7 @@ Options:
2729
--color WHEN Coloring: auto, always, never
2830
--frozen Require Cargo.lock and cache are up to date
2931
--locked Require Cargo.lock is up to date
32+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
3033
3134
If a lockfile is available, this command will ensure that all of the git
3235
dependencies and/or registries dependencies are downloaded and locally
@@ -43,7 +46,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
4346
options.flag_quiet,
4447
&options.flag_color,
4548
options.flag_frozen,
46-
options.flag_locked)?;
49+
options.flag_locked,
50+
&options.flag_z)?;
4751
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
4852
let ws = Workspace::new(&root, config)?;
4953
ops::fetch(&ws)?;

src/bin/generate_lockfile.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub struct Options {
1313
flag_color: Option<String>,
1414
flag_frozen: bool,
1515
flag_locked: bool,
16+
#[serde(rename = "flag_Z")]
17+
flag_z: Vec<String>,
1618
}
1719

1820
pub const USAGE: &'static str = "
@@ -29,6 +31,7 @@ Options:
2931
--color WHEN Coloring: auto, always, never
3032
--frozen Require Cargo.lock and cache are up to date
3133
--locked Require Cargo.lock is up to date
34+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
3235
";
3336

3437
pub fn execute(options: Options, config: &Config) -> CliResult {
@@ -37,7 +40,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
3740
options.flag_quiet,
3841
&options.flag_color,
3942
options.flag_frozen,
40-
options.flag_locked)?;
43+
options.flag_locked,
44+
&options.flag_z)?;
4145
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
4246

4347
let ws = Workspace::new(&root, config)?;

src/bin/git_checkout.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub struct Options {
1111
flag_color: Option<String>,
1212
flag_frozen: bool,
1313
flag_locked: bool,
14+
#[serde(rename = "flag_Z")]
15+
flag_z: Vec<String>,
1416
}
1517

1618
pub const USAGE: &'static str = "
@@ -27,14 +29,16 @@ Options:
2729
--color WHEN Coloring: auto, always, never
2830
--frozen Require Cargo.lock and cache are up to date
2931
--locked Require Cargo.lock is up to date
32+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
3033
";
3134

3235
pub fn execute(options: Options, config: &Config) -> CliResult {
3336
config.configure(options.flag_verbose,
3437
options.flag_quiet,
3538
&options.flag_color,
3639
options.flag_frozen,
37-
options.flag_locked)?;
40+
options.flag_locked,
41+
&options.flag_z)?;
3842
let Options { flag_url: url, flag_reference: reference, .. } = options;
3943

4044
let url = url.to_url()?;

src/bin/init.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub struct Options {
1515
flag_vcs: Option<ops::VersionControl>,
1616
flag_frozen: bool,
1717
flag_locked: bool,
18+
#[serde(rename = "flag_Z")]
19+
flag_z: Vec<String>,
1820
}
1921

2022
pub const USAGE: &'static str = "
@@ -38,6 +40,7 @@ Options:
3840
--color WHEN Coloring: auto, always, never
3941
--frozen Require Cargo.lock and cache are up to date
4042
--locked Require Cargo.lock is up to date
43+
-Z FLAG ... Unstable (nightly-only) flags to Cargo
4144
";
4245

4346
pub fn execute(options: Options, config: &Config) -> CliResult {
@@ -46,7 +49,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
4649
options.flag_quiet,
4750
&options.flag_color,
4851
options.flag_frozen,
49-
options.flag_locked)?;
52+
options.flag_locked,
53+
&options.flag_z)?;
5054

5155
let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options;
5256

0 commit comments

Comments
 (0)