Upgrade rust/crates/anyhow to 1.0.44 am: b66cd5e3ae

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/anyhow/+/1833382

Change-Id: If773761a1c08abfde5c18a605f6b2355f3493d4a
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 85827c5..e50dc09 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "ce33cac487ffe21d3e931e304b2c4f78322b04fd"
+    "sha1": "6c97c59375b24dad08c624cf61d06338f4dc9c3e"
   }
 }
diff --git a/Android.bp b/Android.bp
index aae37b1..9d4715f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,6 +41,8 @@
     name: "anyhow_test_defaults",
     crate_name: "anyhow",
     srcs: ["src/lib.rs"],
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.44",
     test_suites: ["general-tests"],
     auto_gen_config: true,
     edition: "2018",
@@ -71,6 +73,8 @@
 rust_defaults {
     name: "anyhow_test_defaults_anyhow",
     crate_name: "anyhow",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.44",
     test_suites: ["general-tests"],
     auto_gen_config: true,
     edition: "2018",
@@ -255,6 +259,8 @@
     name: "libanyhow",
     host_supported: true,
     crate_name: "anyhow",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.0.44",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: [
@@ -270,33 +276,3 @@
     ],
     min_sdk_version: "29",
 }
-
-// dependent_library ["feature_list"]
-//   autocfg-1.0.1
-//   dissimilar-1.0.2
-//   futures-0.3.15
-//   futures-channel-0.3.15 "futures-sink,sink"
-//   futures-core-0.3.15
-//   futures-io-0.3.15
-//   futures-sink-0.3.15
-//   futures-task-0.3.15
-//   futures-util-0.3.15 "futures-sink,sink"
-//   glob-0.3.0
-//   itoa-0.4.7
-//   lazy_static-1.4.0
-//   pin-project-lite-0.2.7
-//   pin-utils-0.1.0
-//   proc-macro2-1.0.27 "default,proc-macro"
-//   quote-1.0.9 "default,proc-macro"
-//   rustversion-1.0.5
-//   ryu-1.0.5
-//   serde-1.0.126 "default,derive,serde_derive,std"
-//   serde_derive-1.0.126 "default"
-//   serde_json-1.0.64 "default,std"
-//   syn-1.0.73 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote"
-//   termcolor-1.1.2
-//   thiserror-1.0.26
-//   thiserror-impl-1.0.26
-//   toml-0.5.8 "default"
-//   trybuild-1.0.42 "diff,dissimilar"
-//   unicode-xid-0.2.2 "default"
diff --git a/Cargo.toml b/Cargo.toml
index 6886ed3..881fc23 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,17 +3,16 @@
 # When uploading crates to the registry Cargo will automatically
 # "normalize" Cargo.toml files for maximal compatibility
 # with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
 #
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
 
 [package]
 edition = "2018"
 name = "anyhow"
-version = "1.0.42"
+version = "1.0.44"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 description = "Flexible concrete Error type built on std::error::Error"
 documentation = "https://docs.rs/anyhow"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index b09fa7a..97fe475 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "anyhow"
-version = "1.0.42" # remember to update html_root_url
+version = "1.0.44" # remember to update html_root_url
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 edition = "2018"
 license = "MIT OR Apache-2.0"
diff --git a/METADATA b/METADATA
index 141376a..f97422f 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/anyhow/anyhow-1.0.42.crate"
+    value: "https://static.crates.io/crates/anyhow/anyhow-1.0.44.crate"
   }
-  version: "1.0.42"
+  version: "1.0.44"
   license_type: NOTICE
   last_upgrade_date {
     year: 2021
-    month: 7
-    day: 20
+    month: 9
+    day: 22
   }
 }
diff --git a/README.md b/README.md
index c6eb0f1..e10063f 100644
--- a/README.md
+++ b/README.md
@@ -75,10 +75,10 @@
   }
   ```
 
-- If using the nightly channel, a backtrace is captured and printed with the
-  error if the underlying error type does not already provide its own. In order
-  to see backtraces, they must be enabled through the environment variables
-  described in [`std::backtrace`]:
+- If using the nightly channel, or stable with `features = ["backtrace"]`, a
+  a backtrace is captured and printed with the error if the underlying error
+  type does not already provide its own. In order to see backtraces, they must
+  be enabled through the environment variables described in [`std::backtrace`]:
 
   - If you want panics and errors to both have backtraces, set
     `RUST_BACKTRACE=1`;
diff --git a/build.rs b/build.rs
index df2e73b..968e68f 100644
--- a/build.rs
+++ b/build.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::option_if_let_else)]
+
 use std::env;
 use std::fs;
 use std::path::Path;
@@ -67,17 +69,36 @@
     let out_dir = env::var_os("OUT_DIR")?;
     let probefile = Path::new(&out_dir).join("probe.rs");
     fs::write(&probefile, PROBE).ok()?;
-    Command::new(rustc)
-        .stderr(Stdio::null())
+
+    // Make sure to pick up Cargo rustc configuration.
+    let mut cmd = if let Some(wrapper) = env::var_os("CARGO_RUSTC_WRAPPER") {
+        let mut cmd = Command::new(wrapper);
+        // The wrapper's first argument is supposed to be the path to rustc.
+        cmd.arg(rustc);
+        cmd
+    } else {
+        Command::new(rustc)
+    };
+
+    cmd.stderr(Stdio::null())
         .arg("--edition=2018")
         .arg("--crate-name=anyhow_build")
         .arg("--crate-type=lib")
         .arg("--emit=metadata")
         .arg("--out-dir")
         .arg(out_dir)
-        .arg(probefile)
-        .status()
-        .ok()
+        .arg(probefile);
+
+    // If Cargo wants to set RUSTFLAGS, use that.
+    if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
+        if !rustflags.is_empty() {
+            for arg in rustflags.split('\x1f') {
+                cmd.arg(arg);
+            }
+        }
+    }
+
+    cmd.status().ok()
 }
 
 fn rustc_minor_version() -> Option<u32> {
diff --git a/src/chain.rs b/src/chain.rs
index 207e4f0..f7baff2 100644
--- a/src/chain.rs
+++ b/src/chain.rs
@@ -24,6 +24,7 @@
 }
 
 impl<'a> Chain<'a> {
+    #[cold]
     pub fn new(head: &'a (dyn StdError + 'static)) -> Self {
         Chain {
             state: ChainState::Linked { next: Some(head) },
diff --git a/src/error.rs b/src/error.rs
index 92bb63d..3fa0835 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -25,6 +25,7 @@
     /// created here to ensure that a backtrace exists.
     #[cfg(feature = "std")]
     #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
+    #[cold]
     pub fn new<E>(error: E) -> Self
     where
         E: StdError + Send + Sync + 'static,
@@ -70,6 +71,7 @@
     ///         .await
     /// }
     /// ```
+    #[cold]
     pub fn msg<M>(message: M) -> Self
     where
         M: Display + Debug + Send + Sync + 'static,
@@ -78,6 +80,7 @@
     }
 
     #[cfg(feature = "std")]
+    #[cold]
     pub(crate) fn from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self
     where
         E: StdError + Send + Sync + 'static,
@@ -100,6 +103,7 @@
         unsafe { Error::construct(error, vtable, backtrace) }
     }
 
+    #[cold]
     pub(crate) fn from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self
     where
         M: Display + Debug + Send + Sync + 'static,
@@ -125,6 +129,7 @@
         unsafe { Error::construct(error, vtable, backtrace) }
     }
 
+    #[cold]
     pub(crate) fn from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self
     where
         M: Display + Send + Sync + 'static,
@@ -151,6 +156,7 @@
     }
 
     #[cfg(feature = "std")]
+    #[cold]
     pub(crate) fn from_context<C, E>(context: C, error: E, backtrace: Option<Backtrace>) -> Self
     where
         C: Display + Send + Sync + 'static,
@@ -177,6 +183,7 @@
     }
 
     #[cfg(feature = "std")]
+    #[cold]
     pub(crate) fn from_boxed(
         error: Box<dyn StdError + Send + Sync>,
         backtrace: Option<Backtrace>,
@@ -207,6 +214,7 @@
     //
     // Unsafe because the given vtable must have sensible behavior on the error
     // value of type E.
+    #[cold]
     unsafe fn construct<E>(
         error: E,
         vtable: &'static ErrorVTable,
@@ -284,6 +292,7 @@
     ///     })
     /// }
     /// ```
+    #[cold]
     pub fn context<C>(self, context: C) -> Self
     where
         C: Display + Send + Sync + 'static,
@@ -373,6 +382,7 @@
     /// ```
     #[cfg(feature = "std")]
     #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
+    #[cold]
     pub fn chain(&self) -> Chain {
         unsafe { ErrorImpl::chain(self.inner.by_ref()) }
     }
@@ -515,6 +525,7 @@
 where
     E: StdError + Send + Sync + 'static,
 {
+    #[cold]
     fn from(error: E) -> Self {
         let backtrace = backtrace_if_absent!(error);
         Error::from_std(error, backtrace)
@@ -879,6 +890,7 @@
             .expect("backtrace capture failed")
     }
 
+    #[cold]
     pub(crate) unsafe fn chain(this: Ref<Self>) -> Chain {
         Chain::new(Self::error(this))
     }
@@ -917,6 +929,7 @@
 }
 
 impl From<Error> for Box<dyn StdError + Send + Sync + 'static> {
+    #[cold]
     fn from(error: Error) -> Self {
         let outer = ManuallyDrop::new(error);
         unsafe {
diff --git a/src/kind.rs b/src/kind.rs
index eb8d604..5985705 100644
--- a/src/kind.rs
+++ b/src/kind.rs
@@ -62,6 +62,7 @@
 impl<T> AdhocKind for &T where T: ?Sized + Display + Debug + Send + Sync + 'static {}
 
 impl Adhoc {
+    #[cold]
     pub fn new<M>(self, message: M) -> Error
     where
         M: Display + Debug + Send + Sync + 'static,
@@ -82,6 +83,7 @@
 impl<E> TraitKind for E where E: Into<Error> {}
 
 impl Trait {
+    #[cold]
     pub fn new<E>(self, error: E) -> Error
     where
         E: Into<Error>,
@@ -106,6 +108,7 @@
 
 #[cfg(feature = "std")]
 impl Boxed {
+    #[cold]
     pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Error {
         let backtrace = backtrace_if_absent!(error);
         Error::from_boxed(error, backtrace)
diff --git a/src/lib.rs b/src/lib.rs
index b5564fd..2b7a0b1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -128,10 +128,11 @@
 //!   # ;
 //!   ```
 //!
-//! - If using the nightly channel, a backtrace is captured and printed with the
-//!   error if the underlying error type does not already provide its own. In
-//!   order to see backtraces, they must be enabled through the environment
-//!   variables described in [`std::backtrace`]:
+//! - If using the nightly channel, or stable with `features = ["backtrace"]`, a
+//!   backtrace is captured and printed with the error if the underlying error
+//!   type does not already provide its own. In order to see backtraces, they
+//!   must be enabled through the environment variables described in
+//!   [`std::backtrace`]:
 //!
 //!   - If you want panics and errors to both have backtraces, set
 //!     `RUST_BACKTRACE=1`;
@@ -209,7 +210,7 @@
 //! will require an explicit `.map_err(Error::msg)` when working with a
 //! non-Anyhow error type inside a function that returns Anyhow's error type.
 
-#![doc(html_root_url = "https://docs.rs/anyhow/1.0.42")]
+#![doc(html_root_url = "https://docs.rs/anyhow/1.0.44")]
 #![cfg_attr(backtrace, feature(backtrace))]
 #![cfg_attr(doc_cfg, feature(doc_cfg))]
 #![cfg_attr(not(feature = "std"), no_std)]
@@ -625,6 +626,7 @@
         pub use crate::kind::BoxedKind;
     }
 
+    #[cold]
     pub fn new_adhoc<M>(message: M) -> Error
     where
         M: Display + Debug + Send + Sync + 'static,