diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/anyhow/src | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anyhow/src')
-rw-r--r-- | vendor/anyhow/src/context.rs | 19 | ||||
-rw-r--r-- | vendor/anyhow/src/lib.rs | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/vendor/anyhow/src/context.rs b/vendor/anyhow/src/context.rs index 238473e5c..9df86937b 100644 --- a/vendor/anyhow/src/context.rs +++ b/vendor/anyhow/src/context.rs @@ -4,7 +4,7 @@ use core::convert::Infallible; use core::fmt::{self, Debug, Display, Write}; #[cfg(backtrace)] -use std::any::Demand; +use std::any::{Demand, Provider}; mod ext { use super::*; @@ -92,7 +92,12 @@ impl<T> Context<T, Infallible> for Option<T> { where C: Display + Send + Sync + 'static, { - self.ok_or_else(|| Error::from_display(context, backtrace!())) + // Not using ok_or_else to save 2 useless frames off the captured + // backtrace. + match self { + Some(ok) => Ok(ok), + None => Err(Error::from_display(context, backtrace!())), + } } fn with_context<C, F>(self, context: F) -> Result<T, Error> @@ -100,7 +105,10 @@ impl<T> Context<T, Infallible> for Option<T> { C: Display + Send + Sync + 'static, F: FnOnce() -> C, { - self.ok_or_else(|| Error::from_display(context(), backtrace!())) + match self { + Some(ok) => Ok(ok), + None => Err(Error::from_display(context(), backtrace!())), + } } } @@ -137,7 +145,7 @@ where #[cfg(backtrace)] fn provide<'a>(&'a self, demand: &mut Demand<'a>) { - self.error.provide(demand); + StdError::provide(&self.error, demand); } } @@ -151,8 +159,7 @@ where #[cfg(backtrace)] fn provide<'a>(&'a self, demand: &mut Demand<'a>) { - demand.provide_ref(self.error.backtrace()); - self.error.provide(demand); + Provider::provide(&self.error, demand); } } diff --git a/vendor/anyhow/src/lib.rs b/vendor/anyhow/src/lib.rs index 583ab424e..3510d195e 100644 --- a/vendor/anyhow/src/lib.rs +++ b/vendor/anyhow/src/lib.rs @@ -210,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.66")] +#![doc(html_root_url = "https://docs.rs/anyhow/1.0.68")] #![cfg_attr(backtrace, feature(error_generic_member_access, provide_any))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(not(feature = "std"), no_std)] |