Skip to content

Commit c18275b

Browse files
committed
Guard that array value of build.target should be in nightly
1 parent 3c8ba9a commit c18275b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/cargo/util/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,8 +2224,8 @@ impl BuildTargetConfig {
22242224
let values = match &self.inner.val {
22252225
BuildTargetConfigInner::One(s) => vec![map(s)],
22262226
BuildTargetConfigInner::Many(v) => {
2227-
if v.len() > 1 && !config.cli_unstable().multitarget {
2228-
bail!("specifying multiple `target` in `build.target` config value requires `-Zmultitarget`")
2227+
if !config.cli_unstable().multitarget {
2228+
bail!("specifying an array in `build.target` config value requires `-Zmultitarget`")
22292229
} else {
22302230
v.iter().map(map).collect()
22312231
}

tests/testsuite/multitarget.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn double_target_rejected() {
1616
}
1717

1818
#[cargo_test]
19-
fn double_target_rejected_with_config() {
19+
fn array_of_target_rejected_with_config() {
2020
let p = project()
2121
.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
2222
.file("src/main.rs", "fn main() {}")
@@ -30,7 +30,24 @@ fn double_target_rejected_with_config() {
3030
.build();
3131

3232
p.cargo("build")
33-
.with_stderr("[ERROR] specifying multiple `target` in `build.target` config value requires `-Zmultitarget`")
33+
.with_stderr(
34+
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
35+
)
36+
.with_status(101)
37+
.run();
38+
39+
p.change_file(
40+
".cargo/config.toml",
41+
r#"
42+
[build]
43+
target = ["a"]
44+
"#,
45+
);
46+
47+
p.cargo("build")
48+
.with_stderr(
49+
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
50+
)
3451
.with_status(101)
3552
.run();
3653
}

0 commit comments

Comments
 (0)