aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-10-26 13:16:41 -0700
committerChih-Hung Hsieh <chh@google.com>2020-10-26 13:16:41 -0700
commit764ad83479898424e90870a1559aa1f67b272f06 (patch)
tree1c05fe924da61d7e55e82b7a95228f83e54dc33b
parent434fa0df6db96ad43c2bdd94067be2553ead0a28 (diff)
downloadanyhow-764ad83479898424e90870a1559aa1f67b272f06.tar.gz
Upgrade rust/crates/anyhow to 1.0.33
Test: make Change-Id: Ic3f1bb8a16529c19ca64736833b021c5ffe64603
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA8
-rw-r--r--src/error.rs10
-rw-r--r--src/lib.rs2
-rw-r--r--src/macros.rs25
-rw-r--r--tests/compiletest.rs1
-rw-r--r--tests/ui/no-impl.stderr6
9 files changed, 32 insertions, 26 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 46e994b..37e38f8 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "5a193636c3ebaec353bba13d62feeeb55d86f77a"
+ "sha1": "840afd84e9dd91ac5340c05afadeecbe45d0b810"
}
}
diff --git a/Cargo.toml b/Cargo.toml
index 2249ff4..ebb6eab 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "anyhow"
-version = "1.0.32"
+version = "1.0.33"
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 2093265..42f0491 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "anyhow"
-version = "1.0.32" # remember to update html_root_url
+version = "1.0.33" # 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 4a8de8c..1766464 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/anyhow/anyhow-1.0.32.crate"
+ value: "https://static.crates.io/crates/anyhow/anyhow-1.0.33.crate"
}
- version: "1.0.32"
+ version: "1.0.33"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 8
- day: 27
+ month: 10
+ day: 26
}
}
diff --git a/src/error.rs b/src/error.rs
index f9645bf..5d48119 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -80,7 +80,6 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<E>,
object_ref: object_ref::<E>,
- #[cfg(feature = "std")]
object_mut: object_mut::<E>,
object_boxed: object_boxed::<E>,
object_downcast: object_downcast::<E>,
@@ -144,7 +143,6 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<ContextError<C, E>>,
object_ref: object_ref::<ContextError<C, E>>,
- #[cfg(feature = "std")]
object_mut: object_mut::<ContextError<C, E>>,
object_boxed: object_boxed::<ContextError<C, E>>,
object_downcast: context_downcast::<C, E>,
@@ -165,7 +163,6 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<BoxedError>,
object_ref: object_ref::<BoxedError>,
- #[cfg(feature = "std")]
object_mut: object_mut::<BoxedError>,
object_boxed: object_boxed::<BoxedError>,
object_downcast: object_downcast::<Box<dyn StdError + Send + Sync>>,
@@ -343,12 +340,7 @@ impl Error {
/// [`chain()`][Error::chain].
#[cfg(feature = "std")]
pub fn root_cause(&self) -> &(dyn StdError + 'static) {
- let mut chain = self.chain();
- let mut root_cause = chain.next().unwrap();
- for cause in chain {
- root_cause = cause;
- }
- root_cause
+ self.chain().last().unwrap()
}
/// Returns true if `E` is the type held by this error object.
diff --git a/src/lib.rs b/src/lib.rs
index c9f6e90..c38d8d7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -197,7 +197,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.32")]
+#![doc(html_root_url = "https://docs.rs/anyhow/1.0.33")]
#![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 15a9208..c83dfa5 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1,6 +1,9 @@
/// Return early with an error.
///
-/// This macro is equivalent to `return Err(From::from($err))`.
+/// This macro is equivalent to `return Err(`[`anyhow!($args...)`][anyhow!]`)`.
+///
+/// The surrounding function's or closure's return value is required to be
+/// `Result<_,`[`anyhow::Error`][crate::Error]`>`.
///
/// # Example
///
@@ -62,7 +65,11 @@ macro_rules! bail {
/// Return early with an error if a condition is not satisfied.
///
-/// This macro is equivalent to `if !$cond { return Err(From::from($err)); }`.
+/// This macro is equivalent to `if !$cond { return
+/// Err(`[`anyhow!($args...)`][anyhow!]`); }`.
+///
+/// The surrounding function's or closure's return value is required to be
+/// `Result<_,`[`anyhow::Error`][crate::Error]`>`.
///
/// Analogously to `assert!`, `ensure!` takes a condition and exits the function
/// if the condition fails. Unlike `assert!`, `ensure!` returns an `Error`
@@ -123,11 +130,17 @@ macro_rules! ensure {
};
}
-/// Construct an ad-hoc error from a string.
+/// Construct an ad-hoc error from a string or existing non-`anyhow` error
+/// value.
+///
+/// This evaluates to an [`Error`][crate::Error]. It can take either just a
+/// string, or a format string with arguments. It also can take any custom type
+/// which implements `Debug` and `Display`.
///
-/// This evaluates to an `Error`. It can take either just a string, or a format
-/// string with arguments. It also can take any custom type which implements
-/// `Debug` and `Display`.
+/// If called with a single argument whose type implements `std::error::Error`
+/// (in addition to `Debug` and `Display`, which are always required), then that
+/// Error impl's `source` is preserved as the `source` of the resulting
+/// `anyhow::Error`.
///
/// # Example
///
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index f9aea23..7974a62 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -1,4 +1,5 @@
#[rustversion::attr(not(nightly), ignore)]
+#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
diff --git a/tests/ui/no-impl.stderr b/tests/ui/no-impl.stderr
index 4335e04..0af29af 100644
--- a/tests/ui/no-impl.stderr
+++ b/tests/ui/no-impl.stderr
@@ -4,18 +4,18 @@ error[E0599]: no method named `anyhow_kind` found for reference `&Error` in the
4 | struct Error;
| -------------
| |
+ | doesn't satisfy `Error: Into<anyhow::Error>`
| doesn't satisfy `Error: anyhow::private::kind::TraitKind`
- | doesn't satisfy `Error: std::convert::Into<anyhow::Error>`
| doesn't satisfy `Error: std::fmt::Display`
...
7 | let _ = anyhow!(Error);
| ^^^^^^^^^^^^^^ method not found in `&Error`
|
= note: the method `anyhow_kind` exists but the following trait bounds were not satisfied:
- `Error: std::convert::Into<anyhow::Error>`
+ `Error: Into<anyhow::Error>`
which is required by `Error: anyhow::private::kind::TraitKind`
`Error: std::fmt::Display`
which is required by `&Error: anyhow::private::kind::AdhocKind`
- `&Error: std::convert::Into<anyhow::Error>`
+ `&Error: Into<anyhow::Error>`
which is required by `&Error: anyhow::private::kind::TraitKind`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)