Skip to content

Commit

Permalink
Guard that array value of build.target should be in nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Mar 30, 2022
1 parent 3c8ba9a commit c18275b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,8 +2224,8 @@ impl BuildTargetConfig {
let values = match &self.inner.val {
BuildTargetConfigInner::One(s) => vec![map(s)],
BuildTargetConfigInner::Many(v) => {
if v.len() > 1 && !config.cli_unstable().multitarget {
bail!("specifying multiple `target` in `build.target` config value requires `-Zmultitarget`")
if !config.cli_unstable().multitarget {
bail!("specifying an array in `build.target` config value requires `-Zmultitarget`")
} else {
v.iter().map(map).collect()
}
Expand Down
21 changes: 19 additions & 2 deletions tests/testsuite/multitarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn double_target_rejected() {
}

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

p.cargo("build")
.with_stderr("[ERROR] specifying multiple `target` in `build.target` config value requires `-Zmultitarget`")
.with_stderr(
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
)
.with_status(101)
.run();

p.change_file(
".cargo/config.toml",
r#"
[build]
target = ["a"]
"#,
);

p.cargo("build")
.with_stderr(
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
)
.with_status(101)
.run();
}
Expand Down

0 comments on commit c18275b

Please sign in to comment.