From 090eb4277f88ed566e46d3be9f122a7c88ea3ef3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 13 Jul 2021 08:21:27 -0700 Subject: [PATCH] Disable the dir-name profile setting. dir-name primarily exists for translating the built-in profiles. In order to simplify the UI, we would like to not expose it to the user for the initial stabilization. The code to support it is kept in case we want to add it in the future. --- src/cargo/util/toml/mod.rs | 20 ++++++++--------- tests/testsuite/profile_custom.rs | 37 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index dc0e61b7a..9d36cd094 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -520,16 +520,16 @@ impl TomlProfile { features.require(Feature::named_profiles())?; } - if self.dir_name.is_some() { - features.require(Feature::named_profiles())?; - } - - // `dir-name` validation - match &self.dir_name { - None => {} - Some(dir_name) => { - Self::validate_name(dir_name, "dir-name")?; - } + if let Some(dir_name) = self.dir_name { + // This is disabled for now, as we would like to stabilize named + // profiles without this, and then decide in the future if it is + // needed. This helps simplify the UI a little. + bail!( + "dir-name=\"{}\" in profile `{}` is not currently allowed, \ + directory names are tied to the profile name for custom profiles", + dir_name, + name + ); } // `inherits` validation diff --git a/tests/testsuite/profile_custom.rs b/tests/testsuite/profile_custom.rs index d8da18eee..7e5761086 100644 --- a/tests/testsuite/profile_custom.rs +++ b/tests/testsuite/profile_custom.rs @@ -100,6 +100,7 @@ Caused by: } #[cargo_test] +#[ignore] // dir-name is currently disabled fn invalid_dir_name() { let p = project() .file( @@ -134,6 +135,42 @@ Caused by: .run(); } +#[cargo_test] +fn dir_name_disabled() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.1.0" + + [profile.release-lto] + inherits = "release" + dir-name = "lto" + lto = true + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +error: failed to parse manifest at `[ROOT]/foo/Cargo.toml` + +Caused by: + dir-name=\"lto\" in profile `release-lto` is not currently allowed, \ + directory names are tied to the profile name for custom profiles +", + ) + .run(); +} + #[cargo_test] fn invalid_inherits() { let p = project()