0

Roll anyhow: 1.0.86 => 1.0.87 in //third_party/rust.

This CL has been created semi-automatically.  The expected review
process and other details can be found at
//tools/crates/create_update_cl.md

Updated crates:

* anyhow: 1.0.86 => 1.0.87

Chromium `supply-chain/config.toml` policy requires that the following
audit criteria are met (note that these are the *minimum* required
criteria and `supply-chain/audits.toml` can and should record a stricter
certification if possible;  see also //docs/rust-unsafe.md):

* anyhow@1.0.87: crypto-safe, safe-to-run

Bug: None
Change-Id: I6cfae02304c2b0b5f6364b06850fe8210ecaca24
Cq-Include-Trybots: chromium/try:android-rust-arm32-rel
Cq-Include-Trybots: chromium/try:android-rust-arm64-dbg
Cq-Include-Trybots: chromium/try:android-rust-arm64-rel
Cq-Include-Trybots: chromium/try:linux-rust-x64-dbg
Cq-Include-Trybots: chromium/try:linux-rust-x64-rel
Cq-Include-Trybots: chromium/try:win-rust-x64-dbg
Cq-Include-Trybots: chromium/try:win-rust-x64-rel
Disable-Rts: True
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5844860
Auto-Submit: Adrian Taylor <adetaylor@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1352842}
This commit is contained in:
Adrian Taylor
2024-09-09 17:13:37 +00:00
committed by Chromium LUCI CQ
parent 1ba221a133
commit c3ebfb0728
62 changed files with 171 additions and 162 deletions

@ -306,7 +306,6 @@ third_party/afl/src/qemu_mode 1 1
third_party/android_build_tools/compose_compiler 1 1
third_party/android_build_tools/gradle_wrapper 1 1
third_party/android_build_tools/json 1 1
third_party/android_deps_autorolled 1 1
third_party/android_deps/buildSrc/src/main/groovy 36 2
third_party/android_deps/libs 1 1
third_party/android_deps/libs/com_google_auto_auto_common 1 1
@ -653,8 +652,8 @@ third_party/rust/chromium_crates_io/vendor/adler-1.0.2/.github/workflows 2 1
third_party/rust/chromium_crates_io/vendor/adler2-2.0.0/.github/workflows 2 1
third_party/rust/chromium_crates_io/vendor/aho-corasick-1.1.3/.github/workflows 5 1
third_party/rust/chromium_crates_io/vendor/anstyle-1.0.8 1 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86 2 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/.github/workflows 3 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87 2 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/.github/workflows 3 1
third_party/rust/chromium_crates_io/vendor/base64-0.13.1 1 1
third_party/rust/chromium_crates_io/vendor/bytes-1.7.1/.github/workflows 3 1
third_party/rust/chromium_crates_io/vendor/cfg-if-1.0.0/.github/workflows 4 1
@ -814,7 +813,6 @@ tools/binary_size/libsupersize 17 6
tools/binary_size/libsupersize/testdata 4 1
tools/checkperms 1 1
tools/crates/gnrt 1 1
tools/cygprofile 1 1
tools/emacs 320 4
tools/git 2 1
tools/mac/power/protos/third_party/pprof 1 1

@ -13,25 +13,25 @@ cargo_crate("lib") {
epoch = "1"
crate_type = "rlib"
crate_root =
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/lib.rs"
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/lib.rs"
sources = [
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/backtrace.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/chain.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/context.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/ensure.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/error.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/fmt.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/kind.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/lib.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/macros.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/ptr.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/src/wrapper.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/backtrace.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/chain.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/context.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/ensure.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/error.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/fmt.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/kind.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/lib.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/macros.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/ptr.rs",
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/src/wrapper.rs",
]
inputs = []
build_native_rust_unit_tests = false
edition = "2018"
cargo_pkg_version = "1.0.86"
cargo_pkg_version = "1.0.87"
cargo_pkg_authors = "David Tolnay <dtolnay@gmail.com>"
cargo_pkg_name = "anyhow"
cargo_pkg_description =
@ -44,9 +44,9 @@ cargo_crate("lib") {
proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ]
features = [ "std" ]
build_root =
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/build.rs"
"//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/build.rs"
build_sources =
[ "//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/build.rs" ]
[ "//third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/build.rs" ]
testonly = true
}

@ -1,9 +1,9 @@
Name: anyhow
URL: https://crates.io/crates/anyhow
Description: Flexible concrete Error type built on std::error::Error
Version: 1.0.86
Version: 1.0.87
Security Critical: no
Shipped: no
License: Apache 2.0
License File: //third_party/rust/chromium_crates_io/vendor/anyhow-1.0.86/LICENSE-APACHE
Revision: 8ea1819c4c7829d0eb09e54a52806f382b8d445b
License File: //third_party/rust/chromium_crates_io/vendor/anyhow-1.0.87/LICENSE-APACHE
Revision: afe93e7b167d069ac79f2c7f363b919d3793e6ce

@ -27,7 +27,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "anyhow"
version = "1.0.86"
version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]

@ -178,6 +178,12 @@ criteria = ["safe-to-run", "does-not-implement-crypto"]
delta = "1.0.83 -> 1.0.86"
notes = "Delta only updates the ensure macro implementation, still safe to run, no crypto"
[[audits.anyhow]]
who = "Adrian Taylor <adetaylor@chromium.org>"
criteria = ["safe-to-run", "does-not-implement-crypto"]
delta = "1.0.86 -> 1.0.87"
notes = "Minimal changes, mostly renaming std to core for a type"
[[audits.autocfg]]
who = "Lukasz Anforowicz <lukasza@chromium.org>"
criteria = ["ub-risk-0", "safe-to-deploy", "does-not-implement-crypto"]

@ -53,7 +53,7 @@ criteria = ["crypto-safe", "safe-to-run"]
[policy."anstyle:1.0.8"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."anyhow:1.0.86"]
[policy."anyhow:1.0.87"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."base64:0.13.1"]
@ -337,7 +337,7 @@ criteria = ["crypto-safe", "safe-to-run"]
[[exemptions.cxx]]
version = "1.0.128"
criteria = ["safe-to-deploy", "ub-risk-2", "crypto-safe"]
criteria = ["safe-to-deploy", "crypto-safe", "ub-risk-2"]
notes = """
Grandparented-in when setting up `cargo vet` in Jan 2024
@ -355,7 +355,7 @@ Exemption updated to 1.0.128 in September 2024.
[[exemptions.cxxbridge-macro]]
version = "1.0.128"
criteria = ["safe-to-deploy", "ub-risk-2", "crypto-safe"]
criteria = ["safe-to-deploy", "crypto-safe", "ub-risk-2"]
notes = """
Grandparented-in when setting up `cargo vet` in Jan 2024

@ -1,6 +0,0 @@
{
"git": {
"sha1": "8ea1819c4c7829d0eb09e54a52806f382b8d445b"
},
"path_in_vcs": ""
}

@ -1,7 +0,0 @@
#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}

@ -0,0 +1,6 @@
{
"git": {
"sha1": "afe93e7b167d069ac79f2c7f363b919d3793e6ce"
},
"path_in_vcs": ""
}

@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable, 1.70.0]
rust: [nightly, beta, stable, 1.80.0, 1.70.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
@ -41,6 +41,11 @@ jobs:
- run: cargo test
- run: cargo check --no-default-features
- run: cargo check --features backtrace
- uses: actions/upload-artifact@v4
if: matrix.rust == 'nightly' && always()
with:
name: Cargo.lock
path: Cargo.lock
build:
name: Rust ${{matrix.rust}}
@ -50,7 +55,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [1.65.0, 1.52.0, 1.51.0, 1.50.0, 1.39.0]
rust: [1.67.0, 1.65.0, 1.52.0, 1.51.0, 1.50.0, 1.39.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
@ -61,7 +66,7 @@ jobs:
- run: cargo check
- run: cargo check --no-default-features
- run: cargo check --features backtrace
if: matrix.rust != '1.52.0' && matrix.rust != '1.51.0' && matrix.rust != '1.50.0' && matrix.rust != '1.39.0'
if: matrix.rust != '1.65.0' && matrix.rust != '1.52.0' && matrix.rust != '1.51.0' && matrix.rust != '1.50.0' && matrix.rust != '1.39.0'
minimal:
name: Minimal versions

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.39"
name = "anyhow"
version = "1.0.86"
version = "1.0.87"
authors = ["David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
autobins = false
@ -35,11 +35,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/dtolnay/anyhow"
[package.metadata.docs.rs]
rustdoc-args = [
"--cfg",
"doc_cfg",
"--generate-link-to-definition",
]
rustdoc-args = ["--generate-link-to-definition"]
targets = ["x86_64-unknown-linux-gnu"]
[lib]
@ -48,61 +44,61 @@ path = "src/lib.rs"
doc-scrape-examples = false
[[test]]
name = "test_ensure"
path = "tests/test_ensure.rs"
[[test]]
name = "test_chain"
path = "tests/test_chain.rs"
[[test]]
name = "test_fmt"
path = "tests/test_fmt.rs"
[[test]]
name = "test_source"
path = "tests/test_source.rs"
[[test]]
name = "test_repr"
path = "tests/test_repr.rs"
name = "compiletest"
path = "tests/compiletest.rs"
[[test]]
name = "test_autotrait"
path = "tests/test_autotrait.rs"
[[test]]
name = "test_boxed"
path = "tests/test_boxed.rs"
[[test]]
name = "test_backtrace"
path = "tests/test_backtrace.rs"
[[test]]
name = "test_convert"
path = "tests/test_convert.rs"
name = "test_boxed"
path = "tests/test_boxed.rs"
[[test]]
name = "test_macros"
path = "tests/test_macros.rs"
[[test]]
name = "compiletest"
path = "tests/compiletest.rs"
name = "test_chain"
path = "tests/test_chain.rs"
[[test]]
name = "test_context"
path = "tests/test_context.rs"
[[test]]
name = "test_ffi"
path = "tests/test_ffi.rs"
name = "test_convert"
path = "tests/test_convert.rs"
[[test]]
name = "test_downcast"
path = "tests/test_downcast.rs"
[[test]]
name = "test_ensure"
path = "tests/test_ensure.rs"
[[test]]
name = "test_ffi"
path = "tests/test_ffi.rs"
[[test]]
name = "test_fmt"
path = "tests/test_fmt.rs"
[[test]]
name = "test_macros"
path = "tests/test_macros.rs"
[[test]]
name = "test_repr"
path = "tests/test_repr.rs"
[[test]]
name = "test_source"
path = "tests/test_source.rs"
[dependencies.backtrace]
version = "0.3.51"
optional = true

@ -1,6 +1,6 @@
[package]
name = "anyhow"
version = "1.0.86"
version = "1.0.87"
authors = ["David Tolnay <dtolnay@gmail.com>"]
categories = ["rust-patterns", "no-std"]
description = "Flexible concrete Error type built on std::error::Error"
@ -34,4 +34,4 @@ doc-scrape-examples = false
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--cfg", "doc_cfg", "--generate-link-to-definition"]
rustdoc-args = ["--generate-link-to-definition"]

@ -67,10 +67,10 @@ fn main() {
if rustc >= 80 {
println!("cargo:rustc-check-cfg=cfg(anyhow_nightly_testing)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_error)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_fmt_arguments_as_str)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_ptr_addr_of)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_unsafe_op_in_unsafe_fn_lint)");
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
println!("cargo:rustc-check-cfg=cfg(error_generic_member_access)");
println!("cargo:rustc-check-cfg=cfg(std_backtrace)");
}
@ -96,6 +96,12 @@ fn main() {
// https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis
println!("cargo:rustc-cfg=std_backtrace");
}
if rustc < 81 {
// core::error::Error
// https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#coreerrorerror
println!("cargo:rustc-cfg=anyhow_no_core_error");
}
}
fn compile_probe(rustc_bootstrap: bool) -> bool {

@ -4,9 +4,9 @@
#![feature(error_generic_member_access)]
use core::error::{self, Error, Request};
use core::fmt::{self, Debug, Display};
use std::backtrace::Backtrace;
use std::error::{self, Error, Request};
use std::fmt::{self, Debug, Display};
struct MyError(Thing);
struct Thing;

@ -38,7 +38,8 @@ macro_rules! backtrace {
#[cfg(error_generic_member_access)]
macro_rules! backtrace_if_absent {
($err:expr) => {
match std::error::request_ref::<std::backtrace::Backtrace>($err as &dyn std::error::Error) {
match core::error::request_ref::<std::backtrace::Backtrace>($err as &dyn core::error::Error)
{
Some(_) => None,
None => backtrace!(),
}
@ -46,7 +47,7 @@ macro_rules! backtrace_if_absent {
}
#[cfg(all(
feature = "std",
any(feature = "std", not(anyhow_no_core_error)),
not(error_generic_member_access),
any(std_backtrace, feature = "backtrace")
))]
@ -56,7 +57,11 @@ macro_rules! backtrace_if_absent {
};
}
#[cfg(all(feature = "std", not(std_backtrace), not(feature = "backtrace")))]
#[cfg(all(
any(feature = "std", not(anyhow_no_core_error)),
not(std_backtrace),
not(feature = "backtrace"),
))]
macro_rules! backtrace_if_absent {
($err:expr) => {
None

@ -1,13 +1,13 @@
use self::ChainState::*;
use crate::StdError;
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use alloc::vec::{self, Vec};
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
pub(crate) use crate::Chain;
#[cfg(not(feature = "std"))]
#[cfg(all(not(feature = "std"), anyhow_no_core_error))]
pub(crate) struct Chain<'a> {
state: ChainState<'a>,
}
@ -17,7 +17,7 @@ pub(crate) enum ChainState<'a> {
Linked {
next: Option<&'a (dyn StdError + 'static)>,
},
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
Buffered {
rest: vec::IntoIter<&'a (dyn StdError + 'static)>,
},
@ -42,7 +42,7 @@ impl<'a> Iterator for Chain<'a> {
*next = error.source();
Some(error)
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
Buffered { rest } => rest.next(),
}
}
@ -53,7 +53,7 @@ impl<'a> Iterator for Chain<'a> {
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl DoubleEndedIterator for Chain<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
match &mut self.state {
@ -84,13 +84,13 @@ impl ExactSizeIterator for Chain<'_> {
}
len
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
Buffered { rest } => rest.len(),
}
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl Default for Chain<'_> {
fn default() -> Self {
Chain {

@ -4,7 +4,7 @@ use core::convert::Infallible;
use core::fmt::{self, Debug, Display, Write};
#[cfg(error_generic_member_access)]
use std::error::Request;
use core::error::Request;
mod ext {
use super::*;
@ -15,10 +15,10 @@ mod ext {
C: Display + Send + Sync + 'static;
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl<E> StdError for E
where
E: std::error::Error + Send + Sync + 'static,
E: crate::StdError + Send + Sync + 'static,
{
fn ext_context<C>(self, context: C) -> Error
where

@ -1,21 +1,20 @@
use crate::backtrace::Backtrace;
use crate::chain::Chain;
#[cfg(any(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(any(feature = "std", not(anyhow_no_core_error), anyhow_no_ptr_addr_of))]
use crate::ptr::Mut;
use crate::ptr::{Own, Ref};
use crate::{Error, StdError};
use alloc::boxed::Box;
use core::any::TypeId;
#[cfg(error_generic_member_access)]
use core::error::{self, Request};
use core::fmt::{self, Debug, Display};
use core::mem::ManuallyDrop;
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use core::ops::{Deref, DerefMut};
#[cfg(not(anyhow_no_ptr_addr_of))]
use core::ptr;
use core::ptr::NonNull;
#[cfg(error_generic_member_access)]
use std::error::{self, Request};
#[cfg(feature = "std")]
use core::ops::{Deref, DerefMut};
impl Error {
/// Create a new error object from any error type.
@ -25,8 +24,7 @@ impl Error {
///
/// If the error type does not provide a backtrace, a backtrace will be
/// created here to ensure that a backtrace exists.
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[cold]
#[must_use]
pub fn new<E>(error: E) -> Self
@ -83,7 +81,7 @@ impl Error {
Error::from_adhoc(message, backtrace!())
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[cold]
pub(crate) fn from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self
where
@ -120,7 +118,7 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<MessageError<M>>,
object_ref: object_ref::<MessageError<M>>,
#[cfg(all(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(all(any(feature = "std", not(anyhow_no_core_error)), anyhow_no_ptr_addr_of))]
object_mut: object_mut::<MessageError<M>>,
object_boxed: object_boxed::<MessageError<M>>,
object_downcast: object_downcast::<M>,
@ -149,7 +147,7 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<DisplayError<M>>,
object_ref: object_ref::<DisplayError<M>>,
#[cfg(all(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(all(any(feature = "std", not(anyhow_no_core_error)), anyhow_no_ptr_addr_of))]
object_mut: object_mut::<DisplayError<M>>,
object_boxed: object_boxed::<DisplayError<M>>,
object_downcast: object_downcast::<M>,
@ -168,7 +166,7 @@ impl Error {
unsafe { Error::construct(error, vtable, backtrace) }
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[cold]
pub(crate) fn from_context<C, E>(context: C, error: E, backtrace: Option<Backtrace>) -> Self
where
@ -198,7 +196,7 @@ impl Error {
unsafe { Error::construct(error, vtable, backtrace) }
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[cold]
pub(crate) fn from_boxed(
error: Box<dyn StdError + Send + Sync>,
@ -325,7 +323,7 @@ impl Error {
let vtable = &ErrorVTable {
object_drop: object_drop::<ContextError<C, Error>>,
object_ref: object_ref::<ContextError<C, Error>>,
#[cfg(all(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(all(any(feature = "std", not(anyhow_no_core_error)), anyhow_no_ptr_addr_of))]
object_mut: object_mut::<ContextError<C, Error>>,
object_boxed: object_boxed::<ContextError<C, Error>>,
object_downcast: context_chain_downcast::<C>,
@ -399,8 +397,7 @@ impl Error {
/// None
/// }
/// ```
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[cold]
pub fn chain(&self) -> Chain {
unsafe { ErrorImpl::chain(self.inner.by_ref()) }
@ -411,8 +408,7 @@ impl Error {
///
/// The root cause is the last error in the iterator produced by
/// [`chain()`][Error::chain].
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
pub fn root_cause(&self) -> &(dyn StdError + 'static) {
self.chain().last().unwrap()
}
@ -554,8 +550,7 @@ impl Error {
}
}
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl<E> From<E> for Error
where
E: StdError + Send + Sync + 'static,
@ -567,8 +562,7 @@ where
}
}
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl Deref for Error {
type Target = dyn StdError + Send + Sync + 'static;
@ -577,8 +571,7 @@ impl Deref for Error {
}
}
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl DerefMut for Error {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { ErrorImpl::error_mut(self.inner.by_mut()) }
@ -609,7 +602,7 @@ impl Drop for Error {
struct ErrorVTable {
object_drop: unsafe fn(Own<ErrorImpl>),
object_ref: unsafe fn(Ref<ErrorImpl>) -> Ref<dyn StdError + Send + Sync + 'static>,
#[cfg(all(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(all(any(feature = "std", not(anyhow_no_core_error)), anyhow_no_ptr_addr_of))]
object_mut: unsafe fn(Mut<ErrorImpl>) -> &mut (dyn StdError + Send + Sync + 'static),
object_boxed: unsafe fn(Own<ErrorImpl>) -> Box<dyn StdError + Send + Sync + 'static>,
object_downcast: unsafe fn(Ref<ErrorImpl>, TypeId) -> Option<Ref<()>>,
@ -661,7 +654,7 @@ where
// Safety: requires layout of *e to match ErrorImpl<E>, and for `e` to be derived
// from a `&mut`
#[cfg(all(feature = "std", anyhow_no_ptr_addr_of))]
#[cfg(all(any(feature = "std", not(anyhow_no_core_error)), anyhow_no_ptr_addr_of))]
unsafe fn object_mut<E>(e: Mut<ErrorImpl>) -> &mut (dyn StdError + Send + Sync + 'static)
where
E: StdError + Send + Sync + 'static,
@ -734,7 +727,7 @@ fn no_backtrace(e: Ref<ErrorImpl>) -> Option<&Backtrace> {
}
// Safety: requires layout of *e to match ErrorImpl<ContextError<C, E>>.
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
unsafe fn context_downcast<C, E>(e: Ref<ErrorImpl>, target: TypeId) -> Option<Ref<()>>
where
C: 'static,
@ -774,7 +767,7 @@ where
}
// Safety: requires layout of *e to match ErrorImpl<ContextError<C, E>>.
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
unsafe fn context_drop_rest<C, E>(e: Own<ErrorImpl>, target: TypeId)
where
C: 'static,
@ -906,7 +899,7 @@ impl ErrorImpl {
unsafe { (vtable(this.ptr).object_ref)(this).deref() }
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
pub(crate) unsafe fn error_mut(this: Mut<Self>) -> &mut (dyn StdError + Send + Sync + 'static) {
// Use vtable to attach E's native StdError vtable for the right
// original type E.
@ -1009,14 +1002,14 @@ impl From<Error> for Box<dyn StdError + 'static> {
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl AsRef<dyn StdError + Send + Sync> for Error {
fn as_ref(&self) -> &(dyn StdError + Send + Sync + 'static) {
&**self
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl AsRef<dyn StdError> for Error {
fn as_ref(&self) -> &(dyn StdError + 'static) {
&**self

@ -47,9 +47,9 @@
use crate::Error;
use core::fmt::{Debug, Display};
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use crate::StdError;
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use alloc::boxed::Box;
pub struct Adhoc;
@ -96,10 +96,10 @@ impl Trait {
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
pub struct Boxed;
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[doc(hidden)]
pub trait BoxedKind: Sized {
#[inline]
@ -108,10 +108,10 @@ pub trait BoxedKind: Sized {
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl BoxedKind for Box<dyn StdError + Send + Sync> {}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl Boxed {
#[cold]
pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Error {

@ -206,9 +206,8 @@
//! 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.85")]
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.87")]
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![no_std]
#![deny(dead_code, unused_imports, unused_mut)]
#![cfg_attr(
@ -266,13 +265,16 @@ use crate::error::ErrorImpl;
use crate::ptr::Own;
use core::fmt::Display;
#[cfg(not(feature = "std"))]
#[cfg(all(not(feature = "std"), anyhow_no_core_error))]
use core::fmt::Debug;
#[cfg(feature = "std")]
use std::error::Error as StdError;
#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", anyhow_no_core_error)))]
use core::error::Error as StdError;
#[cfg(all(not(feature = "std"), anyhow_no_core_error))]
trait StdError: Debug + Display {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
None
@ -407,8 +409,7 @@ pub struct Error {
/// None
/// }
/// ```
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[derive(Clone)]
pub struct Chain<'a> {
state: crate::chain::ChainState<'a>,
@ -670,7 +671,7 @@ pub mod __private {
#[doc(hidden)]
pub use crate::kind::{AdhocKind, TraitKind};
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[doc(hidden)]
pub use crate::kind::BoxedKind;
}

@ -1,11 +1,11 @@
use crate::StdError;
use core::fmt::{self, Debug, Display};
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use alloc::boxed::Box;
#[cfg(error_generic_member_access)]
use std::error::Request;
use core::error::Request;
#[repr(transparent)]
pub struct MessageError<M>(pub M);
@ -53,25 +53,25 @@ where
impl<M> StdError for DisplayError<M> where M: Display + 'static {}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
#[repr(transparent)]
pub struct BoxedError(pub Box<dyn StdError + Send + Sync>);
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl Debug for BoxedError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Debug::fmt(&self.0, f)
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl Display for BoxedError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(&self.0, f)
}
}
#[cfg(feature = "std")]
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
impl StdError for BoxedError {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
self.0.source()

@ -0,0 +1,7 @@
#[rustversion::attr(not(nightly), ignore = "requires nightly")]
#[cfg_attr(miri, ignore = "incompatible with miri")]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}

@ -1,7 +1,7 @@
#![allow(clippy::let_underscore_untyped)]
#[rustversion::not(nightly)]
#[ignore]
#[ignore = "requires nightly"]
#[test]
fn test_backtrace() {}

@ -153,18 +153,18 @@ fn test_closure() {
// identifier, nor as `(S + move || 1) == (1)` by misinterpreting the
// closure precedence.
let test = || Ok(ensure!(S + move || 1 == 1));
assert_err(test, "Condition failed: `S + (move || 1 == 1)`");
assert_err(test, "Condition failed: `S + move || 1 == 1`");
let test = || Ok(ensure!(S + || 1 == 1));
assert_err(test, "Condition failed: `S + (|| 1 == 1)`");
assert_err(test, "Condition failed: `S + || 1 == 1`");
// Must not partition as `S + ((move | ()) | 1) == 1` by treating those
// pipes as bitwise-or.
let test = || Ok(ensure!(S + move |()| 1 == 1));
assert_err(test, "Condition failed: `S + (move |()| 1 == 1)`");
assert_err(test, "Condition failed: `S + move |()| 1 == 1`");
let test = || Ok(ensure!(S + |()| 1 == 1));
assert_err(test, "Condition failed: `S + (|()| 1 == 1)`");
assert_err(test, "Condition failed: `S + |()| 1 == 1`");
}
#[test]
@ -224,7 +224,7 @@ fn test_if() {
let test = || Ok(ensure!(if let | 1 | 2 = 2 {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if let 1 | 2 = 2 {}.t(1) == 2` (1 vs 2)",
"Condition failed: `if let | 1 | 2 = 2 {}.t(1) == 2` (1 vs 2)",
);
}
@ -269,7 +269,7 @@ fn test_loop() {
let test = || Ok(ensure!(for | _x in iter::once(0) {}.t(1) == 2));
assert_err(
test,
"Condition failed: `for _x in iter::once(0) {}.t(1) == 2` (1 vs 2)",
"Condition failed: `for | _x in iter::once(0) {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
@ -286,7 +286,7 @@ fn test_match() {
let test = || Ok(ensure!(match 1 == 1 { true => 1, false => 0 } == 2));
assert_err(
test,
"Condition failed: `match 1 == 1 { true => 1, false => 0, } == 2` (1 vs 2)",
"Condition failed: `match 1 == 1 { true => 1, false => 0 } == 2` (1 vs 2)",
);
}
@ -343,7 +343,7 @@ fn test_path() {
let test = || Ok(ensure!(Error::msg::<&str,>.t(1) == 2));
assert_err(
test,
"Condition failed: `Error::msg::<&str>.t(1) == 2` (1 vs 2)",
"Condition failed: `Error::msg::<&str,>.t(1) == 2` (1 vs 2)",
);
let test = || Ok(ensure!(Error::msg::<<str as ToOwned>::Owned>.t(1) == 2));
@ -362,7 +362,7 @@ fn test_path() {
let test = || Ok(ensure!(Chain::<'static,>::new.t(1) == 2));
assert_err(
test,
"Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)",
"Condition failed: `Chain::<'static,>::new.t(1) == 2` (1 vs 2)",
);
fn f<const I: isize>() {}
@ -394,7 +394,7 @@ fn test_path() {
#[rustfmt::skip]
let test = || Ok(ensure!(E::U::<u8,>>E::U));
assert_err(test, "Condition failed: `E::U::<u8> > E::U` (U vs U)");
assert_err(test, "Condition failed: `E::U::<u8,> > E::U` (U vs U)");
let test = || Ok(ensure!(Generic::<dyn Debug + Sync> != Generic));
assert_err(
@ -416,7 +416,7 @@ fn test_path() {
};
assert_err(
test,
"Condition failed: `Generic::<dyn Fn() + ::std::marker::Sync> != Generic` (Generic vs Generic)",
"Condition failed: `Generic::<dyn Fn::() + ::std::marker::Sync> != Generic` (Generic vs Generic)",
);
}

@ -79,7 +79,6 @@ fn test_altdisplay() {
}
#[test]
#[cfg_attr(not(std_backtrace), ignore)]
fn test_debug() {
assert_eq!(EXPECTED_DEBUG_F, format!("{:?}", f().unwrap_err()));
assert_eq!(EXPECTED_DEBUG_G, format!("{:?}", g().unwrap_err()));