diff options
author | Haibo Huang <hhb@google.com> | 2020-11-05 04:22:27 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-11-05 04:22:27 +0000 |
commit | 4aa8184b47065f7e8e5fa6e7025650ab8d319f48 (patch) | |
tree | ee41bde9213f8c26094e72cbf46595beceed88ce | |
parent | d60aa70cb54a5a1afdf0510a4dbf561c65736d67 (diff) | |
parent | 08084b88b86ced679cf444e22f59e16c99abbcbb (diff) | |
download | anyhow-4aa8184b47065f7e8e5fa6e7025650ab8d319f48.tar.gz |
Upgrade rust/crates/anyhow to 1.0.34 am: 738f24df3b am: 54b2d092c9 am: 08084b88b8
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/anyhow/+/1484978
Change-Id: I727e89e361569a0fa412690f6f3f76818df1c74c
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | src/error.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 14 | ||||
-rw-r--r-- | src/macros.rs | 6 |
8 files changed, 31 insertions, 13 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 37e38f8..3a340ff 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "840afd84e9dd91ac5340c05afadeecbe45d0b810" + "sha1": "99c982128458fecb8d1d7aff9478dd77dac0ee3b" } } @@ -13,7 +13,7 @@ [package] edition = "2018" name = "anyhow" -version = "1.0.33" +version = "1.0.34" 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 42f0491..c6f0bd1 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "anyhow" -version = "1.0.33" # remember to update html_root_url +version = "1.0.34" # remember to update html_root_url authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/anyhow/anyhow-1.0.33.crate" + value: "https://static.crates.io/crates/anyhow/anyhow-1.0.34.crate" } - version: "1.0.33" + version: "1.0.34" license_type: NOTICE last_upgrade_date { year: 2020 - month: 10 - day: 26 + month: 11 + day: 2 } } @@ -118,6 +118,12 @@ anyhow = "1.0" return Err(anyhow!("Missing attribute: {}", missing)); ``` + A `bail!` macro is provided as a shorthand for the same early return. + + ```rust + bail!("Missing attribute: {}", missing); + ``` + <br> ## No-std support diff --git a/src/error.rs b/src/error.rs index 5d48119..5ee9e41 100644 --- a/src/error.rs +++ b/src/error.rs @@ -193,7 +193,7 @@ impl Error { _object: error, }); // Erase the concrete type of E from the compile-time type system. This - // is equivalent to the safe unsize coersion from Box<ErrorImpl<E>> to + // is equivalent to the safe unsize coercion from Box<ErrorImpl<E>> to // Box<ErrorImpl<dyn StdError + Send + Sync + 'static>> except that the // result is a thin pointer. The necessary behavior for manipulating the // underlying ErrorImpl<E> is preserved in the vtable provided by the @@ -690,7 +690,7 @@ impl<E> ErrorImpl<E> { fn erase(&self) -> &ErrorImpl<()> { // Erase the concrete type of E but preserve the vtable in self.vtable // for manipulating the resulting thin pointer. This is analogous to an - // unsize coersion. + // unsize coercion. unsafe { &*(self as *const ErrorImpl<E> as *const ErrorImpl<()>) } } } @@ -179,6 +179,18 @@ //! # } //! ``` //! +//! A `bail!` macro is provided as a shorthand for the same early return. +//! +//! ``` +//! # use anyhow::{bail, Result}; +//! # +//! # fn demo() -> Result<()> { +//! # let missing = "..."; +//! bail!("Missing attribute: {}", missing); +//! # Ok(()) +//! # } +//! ``` +//! //! <br> //! //! # No-std support @@ -197,7 +209,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.33")] +#![doc(html_root_url = "https://docs.rs/anyhow/1.0.34")] #![cfg_attr(backtrace, feature(backtrace))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(not(feature = "std"), no_std)] diff --git a/src/macros.rs b/src/macros.rs index c83dfa5..c4b4c80 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -53,13 +53,13 @@ #[macro_export] macro_rules! bail { ($msg:literal $(,)?) => { - return $crate::private::Err($crate::anyhow!($msg)); + return $crate::private::Err($crate::anyhow!($msg)) }; ($err:expr $(,)?) => { - return $crate::private::Err($crate::anyhow!($err)); + return $crate::private::Err($crate::anyhow!($err)) }; ($fmt:expr, $($arg:tt)*) => { - return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)); + return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)) }; } |