diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 1d61db4f572..224885c955d 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -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(()) diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index cf7ef019044..d319ed686c3 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -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")