Skip to content

Commit 090eb42

Browse files
committed
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.
1 parent 38c8ce6 commit 090eb42

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,16 @@ impl TomlProfile {
520520
features.require(Feature::named_profiles())?;
521521
}
522522

523-
if self.dir_name.is_some() {
524-
features.require(Feature::named_profiles())?;
525-
}
526-
527-
// `dir-name` validation
528-
match &self.dir_name {
529-
None => {}
530-
Some(dir_name) => {
531-
Self::validate_name(dir_name, "dir-name")?;
532-
}
523+
if let Some(dir_name) = self.dir_name {
524+
// This is disabled for now, as we would like to stabilize named
525+
// profiles without this, and then decide in the future if it is
526+
// needed. This helps simplify the UI a little.
527+
bail!(
528+
"dir-name=\"{}\" in profile `{}` is not currently allowed, \
529+
directory names are tied to the profile name for custom profiles",
530+
dir_name,
531+
name
532+
);
533533
}
534534

535535
// `inherits` validation

tests/testsuite/profile_custom.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Caused by:
100100
}
101101

102102
#[cargo_test]
103+
#[ignore] // dir-name is currently disabled
103104
fn invalid_dir_name() {
104105
let p = project()
105106
.file(
@@ -134,6 +135,42 @@ Caused by:
134135
.run();
135136
}
136137

138+
#[cargo_test]
139+
fn dir_name_disabled() {
140+
let p = project()
141+
.file(
142+
"Cargo.toml",
143+
r#"
144+
cargo-features = ["named-profiles"]
145+
146+
[package]
147+
name = "foo"
148+
version = "0.1.0"
149+
150+
[profile.release-lto]
151+
inherits = "release"
152+
dir-name = "lto"
153+
lto = true
154+
"#,
155+
)
156+
.file("src/lib.rs", "")
157+
.build();
158+
159+
p.cargo("build")
160+
.masquerade_as_nightly_cargo()
161+
.with_status(101)
162+
.with_stderr(
163+
"\
164+
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
165+
166+
Caused by:
167+
dir-name=\"lto\" in profile `release-lto` is not currently allowed, \
168+
directory names are tied to the profile name for custom profiles
169+
",
170+
)
171+
.run();
172+
}
173+
137174
#[cargo_test]
138175
fn invalid_inherits() {
139176
let p = project()

0 commit comments

Comments
 (0)