Skip ab/6749736 in stage.
Merged-In: I1775272705bfb60764aa85e0cce619831719c768
Change-Id: I9c9e571e4abc1ff2ba2f96504dad2827392baa34
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 12724b4..46e994b 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "022f700a1c67c5cd663c34b8a3c11c6818ec0ecb"
+ "sha1": "5a193636c3ebaec353bba13d62feeeb55d86f77a"
}
}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..bb3c344
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,46 @@
+name: CI
+
+on:
+ push:
+ pull_request:
+ schedule: [cron: "40 1 * * *"]
+
+jobs:
+ test:
+ name: Rust ${{matrix.rust}}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ rust: [nightly, beta, stable]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{matrix.rust}}
+ - run: cargo test
+ - run: cargo check --no-default-features
+
+ nostd:
+ name: Rust 1.36.0
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: dtolnay/rust-toolchain@1.36.0
+ - run: cargo check --no-default-features
+
+ msrv:
+ name: Rust 1.34.0
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: dtolnay/rust-toolchain@1.34.0
+ - run: cargo check
+
+ clippy:
+ name: Clippy
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: dtolnay/rust-toolchain@clippy
+ - run: cargo clippy -- -Dclippy::all
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f1b4c7f..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-language: rust
-
-rust:
- - nightly
- - beta
- - stable
-
-script:
- - cargo test
- - cargo check --no-default-features
-
-matrix:
- include:
- - rust: 1.34.0
- script: cargo check
- - rust: 1.36.0
- script: cargo check --no-default-features
- - rust: nightly
- name: Clippy
- script:
- - rustup component add clippy || travis_terminate 0
- - cargo clippy -- -Dclippy::all
diff --git a/Cargo.toml b/Cargo.toml
index f255547..2249ff4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "anyhow"
-version = "1.0.28"
+version = "1.0.32"
authors = ["David Tolnay <dtolnay@gmail.com>"]
description = "Flexible concrete Error type built on std::error::Error"
documentation = "https://docs.rs/anyhow"
@@ -41,5 +41,3 @@
[features]
default = ["std"]
std = []
-[badges.travis-ci]
-repository = "dtolnay/anyhow"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 011c7c9..2093265 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "anyhow"
-version = "1.0.28" # remember to update html_root_url
+version = "1.0.32" # remember to update html_root_url
authors = ["David Tolnay <dtolnay@gmail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
@@ -10,9 +10,6 @@
readme = "README.md"
categories = ["rust-patterns"]
-[badges]
-travis-ci = { repository = "dtolnay/anyhow" }
-
[features]
default = ["std"]
std = []
diff --git a/METADATA b/METADATA
index 962dd72..4a8de8c 100644
--- a/METADATA
+++ b/METADATA
@@ -1,4 +1,4 @@
-name: anyhow
+name: "anyhow"
description: "Flexible concrete Error type built on std::error::Error"
third_party {
url {
@@ -6,14 +6,14 @@
value: "https://crates.io/crates/anyhow"
}
url {
- type: GIT
- value: "https://github.com/dtolnay/anyhow"
+ type: ARCHIVE
+ value: "https://static.crates.io/crates/anyhow/anyhow-1.0.32.crate"
}
- version: "1.0.28"
+ version: "1.0.32"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 5
- day: 6
+ month: 8
+ day: 27
}
-}
\ No newline at end of file
+}
diff --git a/README.md b/README.md
index d27d008..87b41d7 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,10 @@
Anyhow ¯\\\_(ツ)\_/¯
=========================
-[![Build Status](https://api.travis-ci.com/dtolnay/anyhow.svg?branch=master)](https://travis-ci.com/dtolnay/anyhow)
-[![Latest Version](https://img.shields.io/crates/v/anyhow.svg)](https://crates.io/crates/anyhow)
-[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/anyhow)
+[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/anyhow-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/anyhow)
+[<img alt="crates.io" src="https://img.shields.io/crates/v/anyhow.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/anyhow)
+[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-anyhow-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/anyhow)
+[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/anyhow/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/anyhow/actions?query=branch%3Amaster)
This library provides [`anyhow::Error`][Error], a trait object based error type
for easy idiomatic error handling in Rust applications.
diff --git a/build.rs b/build.rs
index 056164d..d20b072 100644
--- a/build.rs
+++ b/build.rs
@@ -1,7 +1,7 @@
use std::env;
use std::fs;
use std::path::Path;
-use std::process::{Command, ExitStatus};
+use std::process::{Command, ExitStatus, Stdio};
// This code exercises the surface area that we expect of the std Backtrace
// type. If the current toolchain is able to compile it, we go ahead and use
@@ -50,6 +50,7 @@
let probefile = Path::new(&out_dir).join("probe.rs");
fs::write(&probefile, PROBE).ok()?;
Command::new(rustc)
+ .stderr(Stdio::null())
.arg("--edition=2018")
.arg("--crate-name=anyhow_build")
.arg("--crate-type=lib")
diff --git a/src/error.rs b/src/error.rs
index 80d879f..f9645bf 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -781,6 +781,12 @@
}
}
+impl From<Error> for Box<dyn StdError + Send + 'static> {
+ fn from(error: Error) -> Self {
+ Box::<dyn StdError + Send + Sync>::from(error)
+ }
+}
+
impl From<Error> for Box<dyn StdError + 'static> {
fn from(error: Error) -> Self {
Box::<dyn StdError + Send + Sync>::from(error)
diff --git a/src/fmt.rs b/src/fmt.rs
index 16a82ba..be93e1a 100644
--- a/src/fmt.rs
+++ b/src/fmt.rs
@@ -45,12 +45,17 @@
let backtrace = self.backtrace();
if let BacktraceStatus::Captured = backtrace.status() {
let mut backtrace = backtrace.to_string();
+ write!(f, "\n\n")?;
if backtrace.starts_with("stack backtrace:") {
// Capitalize to match "Caused by:"
backtrace.replace_range(0..1, "S");
+ } else {
+ // "stack backtrace:" prefix was removed in
+ // https://github.com/rust-lang/backtrace-rs/pull/286
+ writeln!(f, "Stack backtrace:")?;
}
backtrace.truncate(backtrace.trim_end().len());
- write!(f, "\n\n{}", backtrace)?;
+ write!(f, "{}", backtrace)?;
}
}
diff --git a/src/lib.rs b/src/lib.rs
index c6694ab..c9f6e90 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,11 @@
+//! [![github]](https://github.com/dtolnay/anyhow) [![crates-io]](https://crates.io/crates/anyhow) [![docs-rs]](https://docs.rs/anyhow)
+//!
+//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
+//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
+//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
+//!
+//! <br>
+//!
//! This library provides [`anyhow::Error`][Error], a trait object based error
//! type for easy idiomatic error handling in Rust applications.
//!
@@ -189,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.28")]
+#![doc(html_root_url = "https://docs.rs/anyhow/1.0.32")]
#![cfg_attr(backtrace, feature(backtrace))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
@@ -280,6 +288,15 @@
///
/// Caused by:
/// No such file or directory (os error 2)
+/// ```
+///
+/// and if there is a backtrace available:
+///
+/// ```console
+/// Error: Failed to read instrs from ./path/to/instrs.json
+///
+/// Caused by:
+/// No such file or directory (os error 2)
///
/// Stack backtrace:
/// 0: <E as anyhow::context::ext::StdError>::ext_context
diff --git a/tests/test_macros.rs b/tests/test_macros.rs
index c6888b6..eb1503f 100644
--- a/tests/test_macros.rs
+++ b/tests/test_macros.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::eq_op)]
+
mod common;
use self::common::*;
diff --git a/tests/ui/no-impl.stderr b/tests/ui/no-impl.stderr
index be95737..4335e04 100644
--- a/tests/ui/no-impl.stderr
+++ b/tests/ui/no-impl.stderr
@@ -4,7 +4,7 @@
4 | struct Error;
| -------------
| |
- | doesn't satisfy `Error: anyhow::kind::TraitKind`
+ | doesn't satisfy `Error: anyhow::private::kind::TraitKind`
| doesn't satisfy `Error: std::convert::Into<anyhow::Error>`
| doesn't satisfy `Error: std::fmt::Display`
...
@@ -13,9 +13,9 @@
|
= note: the method `anyhow_kind` exists but the following trait bounds were not satisfied:
`Error: std::convert::Into<anyhow::Error>`
- which is required by `Error: anyhow::kind::TraitKind`
+ which is required by `Error: anyhow::private::kind::TraitKind`
`Error: std::fmt::Display`
- which is required by `&Error: anyhow::kind::AdhocKind`
+ which is required by `&Error: anyhow::private::kind::AdhocKind`
`&Error: std::convert::Into<anyhow::Error>`
- which is required by `&Error: anyhow::kind::TraitKind`
+ 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)