]> git.proxmox.com Git - cargo.git/commitdiff
Guard that array value of `build.target` should be in nightly
authorWeihang Lo <me@weihanglo.tw>
Wed, 30 Mar 2022 23:23:52 +0000 (07:23 +0800)
committerWeihang Lo <me@weihanglo.tw>
Wed, 30 Mar 2022 23:24:01 +0000 (07:24 +0800)
src/cargo/util/config/mod.rs
tests/testsuite/multitarget.rs

index 1886be972eba5d94abfa8f197efe3d28d0ffbe5a..15414ece9afc46cca05a077230e6af8f887a534b 100644 (file)
@@ -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()
                 }
index cecfb073fb12f3756f7192c98502c92095498817..d4aced728f5a56aa6c210ec86a4557b2c7fb3f58 100644 (file)
@@ -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() {}")
@@ -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();
 }