Merge ea003dbefa76feb11888b854ba731224370979b3 on remote branch

Change-Id: Ia13dbcfb51724bc8a50e21cd0c889c7af661c6c5
diff --git a/Android.bp b/Android.bp
index 0dfc4bc..8eacade 100644
--- a/Android.bp
+++ b/Android.bp
@@ -42,6 +42,8 @@
     name: "liblibm",
     host_supported: true,
     crate_name: "libm",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.2.1",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: ["default"],
@@ -52,33 +54,19 @@
     min_sdk_version: "29",
 }
 
-rust_defaults {
-    name: "libm_defaults",
+rust_test {
+    name: "libm_test_src_lib",
+    host_supported: true,
     crate_name: "libm",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.2.1",
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
     edition: "2018",
     features: ["default"],
     proc_macros: ["libno_panic"],
 }
-
-rust_test_host {
-    name: "libm_host_test_src_lib",
-    defaults: ["libm_defaults"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
-    name: "libm_device_test_src_lib",
-    defaults: ["libm_defaults"],
-}
-
-// dependent_library ["feature_list"]
-//   no-panic-0.1.15
-//   proc-macro2-1.0.26 "default,proc-macro"
-//   quote-1.0.9 "default,proc-macro"
-//   syn-1.0.70 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote"
-//   unicode-xid-0.2.1 "default"
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 99842b9..bfdf123 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,14 +1,24 @@
 // Generated by update_crate_tests.py for tests that depend on this crate.
 {
+  "imports": [
+    {
+      "path": "external/rust/crates/quiche"
+    }
+  ],
   "presubmit": [
     {
       "name": "doh_unit_test"
     },
     {
-      "name": "libm_device_test_src_lib"
+      "name": "libm_test_src_lib"
+    }
+  ],
+  "presubmit-rust": [
+    {
+      "name": "doh_unit_test"
     },
     {
-      "name": "quiche_device_test_src_lib"
+      "name": "libm_test_src_lib"
     }
   ]
 }
diff --git a/patches/test_build_fix.patch b/patches/test_build_fix.patch
new file mode 100644
index 0000000..82c3756
--- /dev/null
+++ b/patches/test_build_fix.patch
@@ -0,0 +1,31 @@
+From c18c704856ffa8b3349401300e66796d4cc8d4f5 Mon Sep 17 00:00:00 2001
+From: Jethro Beekman <jethro@fortanix.com>
+Date: Thu, 24 Jun 2021 15:58:36 +0200
+Subject: [PATCH] Fix build failure with latest nightly
+
+---
+ src/math/pow.rs | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/math/pow.rs b/src/math/pow.rs
+index c7fd0df..f79680a 100644
+--- a/src/math/pow.rs
++++ b/src/math/pow.rs
+@@ -604,7 +604,7 @@ mod tests {
+ 
+         // Factoring -1 out:
+         // (negative anything ^ integer should be (-1 ^ integer) * (positive anything ^ integer))
+-        &[POS_ZERO, NEG_ZERO, POS_ONE, NEG_ONE, POS_EVENS, NEG_EVENS]
++        (&[POS_ZERO, NEG_ZERO, POS_ONE, NEG_ONE, POS_EVENS, NEG_EVENS])
+             .iter()
+             .for_each(|int_set| {
+                 int_set.iter().for_each(|int| {
+@@ -616,7 +616,7 @@ mod tests {
+ 
+         // Negative base (imaginary results):
+         // (-anything except 0 and Infinity ^ non-integer should be NAN)
+-        &NEG[1..(NEG.len() - 1)].iter().for_each(|set| {
++        (&NEG[1..(NEG.len() - 1)]).iter().for_each(|set| {
+             set.iter().for_each(|val| {
+                 test_sets(&ALL[3..7], &|v: f64| pow(*val, v), &|_| NAN);
+             })
diff --git a/src/math/pow.rs b/src/math/pow.rs
index ce8e83e..8b5989c 100644
--- a/src/math/pow.rs
+++ b/src/math/pow.rs
@@ -604,7 +604,7 @@
 
         // Factoring -1 out:
         // (negative anything ^ integer should be (-1 ^ integer) * (positive anything ^ integer))
-        &[POS_ZERO, NEG_ZERO, POS_ONE, NEG_ONE, POS_EVENS, NEG_EVENS]
+        (&[POS_ZERO, NEG_ZERO, POS_ONE, NEG_ONE, POS_EVENS, NEG_EVENS])
             .iter()
             .for_each(|int_set| {
                 int_set.iter().for_each(|int| {
@@ -616,7 +616,7 @@
 
         // Negative base (imaginary results):
         // (-anything except 0 and Infinity ^ non-integer should be NAN)
-        &NEG[1..(NEG.len() - 1)].iter().for_each(|set| {
+        (&NEG[1..(NEG.len() - 1)]).iter().for_each(|set| {
             set.iter().for_each(|val| {
                 test_sets(&ALL[3..7], &|v: f64| pow(*val, v), &|_| NAN);
             })