Skip to content

Commit b227fe1

Browse files
committed
Auto merge of #12857 - epage:unstable, r=weihanglo
fix(cli): Provide next steps for bad -Z flag In #5546, they suggested we have a list of them but that would be hard to keep up and works well enough to just always mention it. Fixes #5546
2 parents c269439 + 51aeeb0 commit b227fe1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cargo/core/features.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,10 @@ impl CliUnstable {
10971097
"script" => self.script = parse_empty(k, v)?,
10981098
"target-applies-to-host" => self.target_applies_to_host = parse_empty(k, v)?,
10991099
"unstable-options" => self.unstable_options = parse_empty(k, v)?,
1100-
_ => bail!("unknown `-Z` flag specified: {}", k),
1100+
_ => bail!("\
1101+
unknown `-Z` flag specified: {k}\n\n\
1102+
For available unstable features, see https://doc.rust-lang.org/nightly/cargo/reference/unstable.html\n\
1103+
If you intended to use an unstable rustc feature, try setting `RUSTFLAGS=\"-Z{k}\"`"),
11011104
}
11021105

11031106
Ok(())

tests/testsuite/cargo_features.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,13 @@ fn z_flags_rejected() {
594594
p.cargo("check -Zarg")
595595
.masquerade_as_nightly_cargo(&["test-dummy-unstable"])
596596
.with_status(101)
597-
.with_stderr("error: unknown `-Z` flag specified: arg")
597+
.with_stderr(
598+
r#"error: unknown `-Z` flag specified: arg
599+
600+
For available unstable features, see https://doc.rust-lang.org/nightly/cargo/reference/unstable.html
601+
If you intended to use an unstable rustc feature, try setting `RUSTFLAGS="-Zarg"`
602+
"#,
603+
)
598604
.run();
599605

600606
p.cargo("check -Zprint-im-a-teapot")

0 commit comments

Comments
 (0)