Skip to content

Commit

Permalink
Auto merge of rust-lang#12857 - epage:unstable, r=weihanglo
Browse files Browse the repository at this point in the history
fix(cli): Provide next steps for bad -Z flag

In rust-lang#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 rust-lang#5546
  • Loading branch information
bors committed Oct 19, 2023
2 parents c269439 + 51aeeb0 commit b227fe1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,10 @@ impl CliUnstable {
"script" => self.script = parse_empty(k, v)?,
"target-applies-to-host" => self.target_applies_to_host = parse_empty(k, v)?,
"unstable-options" => self.unstable_options = parse_empty(k, v)?,
_ => bail!("unknown `-Z` flag specified: {}", k),
_ => bail!("\
unknown `-Z` flag specified: {k}\n\n\
For available unstable features, see https://doc.rust-lang.org/nightly/cargo/reference/unstable.html\n\
If you intended to use an unstable rustc feature, try setting `RUSTFLAGS=\"-Z{k}\"`"),
}

Ok(())
Expand Down
8 changes: 7 additions & 1 deletion tests/testsuite/cargo_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,13 @@ fn z_flags_rejected() {
p.cargo("check -Zarg")
.masquerade_as_nightly_cargo(&["test-dummy-unstable"])
.with_status(101)
.with_stderr("error: unknown `-Z` flag specified: arg")
.with_stderr(
r#"error: unknown `-Z` flag specified: arg
For available unstable features, see https://doc.rust-lang.org/nightly/cargo/reference/unstable.html
If you intended to use an unstable rustc feature, try setting `RUSTFLAGS="-Zarg"`
"#,
)
.run();

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

0 comments on commit b227fe1

Please sign in to comment.