Skip to content

Commit 8aa2794

Browse files
committed
Auto merge of #5322 - matklad:correctly-use-unstable-options, r=alexcrichton
Properly use unstable options for out-dir @alexcrichton how exactly are unstable CLI options supposed to be handled? One can do `-Z unstable-options my-opt` (this is done for `registry`, and this pr uses the same approach for `out-dir`). Once can also do `-Z my-opt`. Doc comments say that `-Z my-opt=val` is also possible, but in reality it does not work. This infra was inherited from `rustc`, which is a slightly different use-case, because it does not have subcommands. That is, if you do `-Z my-opt`, it is available for all subcommands, but does not show up in the help... What do you think about having only `-Z unstable-options` to unlock all cli options? Or do we require a finer-graind granularity? Somewhat related, we have a bunch of unstable options already... Do we have tracking issues for them, to know when the time comes to graduate them to stable?
2 parents 9a56660 + 53f8501 commit 8aa2794

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/bin/commands/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
5252
let ws = args.workspace(config)?;
5353
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
5454
compile_opts.export_dir = args.value_of_path("out-dir", config);
55-
if compile_opts.export_dir.is_some() && !config.cli_unstable().out_dir {
55+
if compile_opts.export_dir.is_some() && !config.cli_unstable().unstable_options {
5656
Err(format_err!(
57-
"`--out-dir` flag is unstable, pass `-Z out-dir` to enable it"
57+
"`--out-dir` flag is unstable, pass `-Z unstable-options` to enable it"
5858
))?;
5959
};
6060
ops::compile(&ws, &compile_opts)?;

src/cargo/core/features.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ pub struct CliUnstable {
286286
pub no_index_update: bool,
287287
pub avoid_dev_deps: bool,
288288
pub minimal_versions: bool,
289-
pub out_dir: bool,
290289
}
291290

292291
impl CliUnstable {
@@ -320,7 +319,6 @@ impl CliUnstable {
320319
"no-index-update" => self.no_index_update = true,
321320
"avoid-dev-deps" => self.avoid_dev_deps = true,
322321
"minimal-versions" => self.minimal_versions = true,
323-
"out-dir" => self.out_dir = true,
324322
_ => bail!("unknown `-Z` flag specified: {}", k),
325323
}
326324

tests/testsuite/out_dir.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn binary_with_debug() {
2323
.build();
2424

2525
assert_that(
26-
p.cargo("build -Z out-dir --out-dir out")
26+
p.cargo("build -Z unstable-options --out-dir out")
2727
.masquerade_as_nightly_cargo(),
2828
execs().with_status(0),
2929
);
@@ -60,7 +60,7 @@ fn static_library_with_debug() {
6060
.build();
6161

6262
assert_that(
63-
p.cargo("build -Z out-dir --out-dir out")
63+
p.cargo("build -Z unstable-options --out-dir out")
6464
.masquerade_as_nightly_cargo(),
6565
execs().with_status(0),
6666
);
@@ -97,7 +97,7 @@ fn dynamic_library_with_debug() {
9797
.build();
9898

9999
assert_that(
100-
p.cargo("build -Z out-dir --out-dir out")
100+
p.cargo("build -Z unstable-options --out-dir out")
101101
.masquerade_as_nightly_cargo(),
102102
execs().with_status(0),
103103
);
@@ -133,7 +133,7 @@ fn rlib_with_debug() {
133133
.build();
134134

135135
assert_that(
136-
p.cargo("build -Z out-dir --out-dir out")
136+
p.cargo("build -Z unstable-options --out-dir out")
137137
.masquerade_as_nightly_cargo(),
138138
execs().with_status(0),
139139
);
@@ -186,7 +186,7 @@ fn include_only_the_binary_from_the_current_package() {
186186
.build();
187187

188188
assert_that(
189-
p.cargo("build -Z out-dir --bin foo --out-dir out")
189+
p.cargo("build -Z unstable-options --bin foo --out-dir out")
190190
.masquerade_as_nightly_cargo(),
191191
execs().with_status(0),
192192
);
@@ -215,7 +215,7 @@ fn out_dir_is_a_file() {
215215
File::create(p.root().join("out")).unwrap();
216216

217217
assert_that(
218-
p.cargo("build -Z out-dir --out-dir out")
218+
p.cargo("build -Z unstable-options --out-dir out")
219219
.masquerade_as_nightly_cargo(),
220220
execs()
221221
.with_status(101)
@@ -239,7 +239,7 @@ fn replaces_artifacts() {
239239
.build();
240240

241241
assert_that(
242-
p.cargo("build -Z out-dir --out-dir out")
242+
p.cargo("build -Z unstable-options --out-dir out")
243243
.masquerade_as_nightly_cargo(),
244244
execs().with_status(0),
245245
);
@@ -253,7 +253,7 @@ fn replaces_artifacts() {
253253
p.change_file("src/main.rs", r#"fn main() { println!("bar") }"#);
254254

255255
assert_that(
256-
p.cargo("build -Z out-dir --out-dir out")
256+
p.cargo("build -Z unstable-options --out-dir out")
257257
.masquerade_as_nightly_cargo(),
258258
execs().with_status(0),
259259
);

0 commit comments

Comments
 (0)