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()