aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-15 21:45:43 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-15 21:45:43 +0000
commitb309b8568bd4944b47363bb1ce43da01cb7ca6f5 (patch)
tree94498c519b5f04456421606db31c2a1b2435260e
parent45511025a77c369ac73ecd51eb95615f0acd4ea1 (diff)
parentc476854138b72f5df7f61920f2024411206edcf1 (diff)
downloadthiserror-aml_tz3_314012010.tar.gz
Change-Id: I1007808e92e544af5e58e57ee9af8ac3e1a2f969
-rw-r--r--.cargo_vcs_info.json7
-rw-r--r--.github/workflows/ci.yml10
-rw-r--r--Android.bp15
-rw-r--r--Cargo.toml16
-rw-r--r--Cargo.toml.orig7
-rw-r--r--METADATA10
-rw-r--r--README.md14
-rw-r--r--TEST_MAPPING125
-rw-r--r--cargo2android.json8
-rw-r--r--rust-toolchain.toml2
-rw-r--r--src/aserror.rs28
-rw-r--r--src/lib.rs22
-rw-r--r--tests/test_backtrace.rs39
-rw-r--r--tests/test_deprecated.rs10
-rw-r--r--tests/test_from.rs23
-rw-r--r--tests/test_generics.rs161
-rw-r--r--tests/test_source.rs6
-rw-r--r--tests/test_transparent.rs21
-rw-r--r--tests/ui/bad-field-attr.stderr2
-rw-r--r--tests/ui/concat-display.stderr4
-rw-r--r--tests/ui/duplicate-enum-source.stderr2
-rw-r--r--tests/ui/duplicate-fmt.stderr2
-rw-r--r--tests/ui/duplicate-struct-source.stderr2
-rw-r--r--tests/ui/duplicate-transparent.stderr2
-rw-r--r--tests/ui/from-not-source.stderr2
-rw-r--r--tests/ui/lifetime.stderr4
-rw-r--r--tests/ui/missing-fmt.stderr2
-rw-r--r--tests/ui/no-display.stderr31
-rw-r--r--tests/ui/source-enum-not-error.stderr41
-rw-r--r--tests/ui/source-struct-not-error.stderr39
-rw-r--r--tests/ui/transparent-display.stderr2
-rw-r--r--tests/ui/transparent-enum-many.stderr2
-rw-r--r--tests/ui/transparent-enum-source.stderr2
-rw-r--r--tests/ui/transparent-struct-many.stderr2
-rw-r--r--tests/ui/transparent-struct-source.stderr2
-rw-r--r--tests/ui/unexpected-field-fmt.stderr2
-rw-r--r--tests/ui/unexpected-struct-source.stderr2
-rw-r--r--tests/ui/union.stderr2
38 files changed, 125 insertions, 548 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index cafa20e..349cbda 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,5 @@
{
"git": {
- "sha1": "672e9525bbc2e5682c380d36974f34716b963591"
- },
- "path_in_vcs": ""
-} \ No newline at end of file
+ "sha1": "1b0a84996b9492c0dc5779127a91c930f23a259e"
+ }
+}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 61714b6..263e04c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -21,7 +21,6 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
- components: rust-src
- run: cargo test --all
env:
RUSTFLAGS: ${{matrix.rustflags}}
@@ -37,16 +36,7 @@ jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
- if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@clippy
- run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
-
- outdated:
- name: Outdated
- runs-on: ubuntu-latest
- if: github.event_name != 'pull_request'
- steps:
- - uses: actions/checkout@v2
- - run: cargo outdated --exit-code 1
diff --git a/Android.bp b/Android.bp
index b1dc159..b5ce3cb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,19 +41,20 @@ rust_library {
name: "libthiserror",
host_supported: true,
crate_name: "thiserror",
- cargo_env_compat: true,
- cargo_pkg_version: "1.0.30",
srcs: ["src/lib.rs"],
edition: "2018",
proc_macros: ["libthiserror_impl"],
apex_available: [
"//apex_available:platform",
- "com.android.bluetooth",
- "com.android.compos",
- "com.android.resolv",
- "com.android.uwb",
+ "com.android.resolv",
"com.android.virt",
],
- vendor_available: true,
min_sdk_version: "29",
}
+
+// dependent_library ["feature_list"]
+// proc-macro2-1.0.26 "default,proc-macro"
+// quote-1.0.9 "default,proc-macro"
+// syn-1.0.71 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+// thiserror-impl-1.0.24
+// unicode-xid-0.2.1 "default"
diff --git a/Cargo.toml b/Cargo.toml
index 78c99d6..e3ef65a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,17 +3,17 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies.
+# to registry (e.g., crates.io) dependencies
#
-# If you are reading this file be aware that the original Cargo.toml
-# will likely look very different (and much more reasonable).
-# See Cargo.toml.orig for the original contents.
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
[package]
edition = "2018"
-rust-version = "1.31"
name = "thiserror"
-version = "1.0.30"
+version = "1.0.24"
authors = ["David Tolnay <dtolnay@gmail.com>"]
description = "derive(Error)"
documentation = "https://docs.rs/thiserror"
@@ -24,7 +24,7 @@ repository = "https://github.com/dtolnay/thiserror"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies.thiserror-impl]
-version = "=1.0.30"
+version = "=1.0.24"
[dev-dependencies.anyhow]
version = "1.0"
@@ -35,5 +35,5 @@ version = "1.0"
version = "1.0"
[dev-dependencies.trybuild]
-version = "1.0.49"
+version = "1.0.19"
features = ["diff"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index efa9af1..0517a91 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,9 +1,8 @@
[package]
name = "thiserror"
-version = "1.0.30"
+version = "1.0.24"
authors = ["David Tolnay <dtolnay@gmail.com>"]
edition = "2018"
-rust-version = "1.31"
license = "MIT OR Apache-2.0"
description = "derive(Error)"
repository = "https://github.com/dtolnay/thiserror"
@@ -12,13 +11,13 @@ categories = ["rust-patterns"]
readme = "README.md"
[dependencies]
-thiserror-impl = { version = "=1.0.30", path = "impl" }
+thiserror-impl = { version = "=1.0.24", path = "impl" }
[dev-dependencies]
anyhow = "1.0"
ref-cast = "1.0"
rustversion = "1.0"
-trybuild = { version = "1.0.49", features = ["diff"] }
+trybuild = { version = "1.0.19", features = ["diff"] }
[workspace]
members = ["impl"]
diff --git a/METADATA b/METADATA
index e961418..3b9f5d5 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/thiserror/thiserror-1.0.30.crate"
+ value: "https://static.crates.io/crates/thiserror/thiserror-1.0.24.crate"
}
- version: "1.0.30"
+ version: "1.0.24"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 3
- day: 1
+ year: 2021
+ month: 2
+ day: 18
}
}
diff --git a/README.md b/README.md
index e12b693..76c436a 100644
--- a/README.md
+++ b/README.md
@@ -137,20 +137,6 @@ pub enum DataStoreError {
}
```
-- If a field is both a source (named `source`, or has `#[source]` or `#[from]`
- attribute) *and* is marked `#[backtrace]`, then the Error trait's
- `backtrace()` method is forwarded to the source's backtrace.
-
- ```rust
- #[derive(Error, Debug)]
- pub enum MyError {
- Io {
- #[backtrace]
- source: io::Error,
- },
- }
- ```
-
- Errors may use `error(transparent)` to forward the source and Display methods
straight through to an underlying error without adding an additional message.
This would be appropriate for enums that need an "anything else" variant.
diff --git a/TEST_MAPPING b/TEST_MAPPING
index eea7991..c21ac98 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,150 +1,53 @@
// Generated by update_crate_tests.py for tests that depend on this crate.
{
- "imports": [
- {
- "path": "external/rust/crates/anyhow"
- },
- {
- "path": "external/rust/crates/jni"
- },
- {
- "path": "external/rust/crates/serde-xml-rs"
- }
- ],
"presubmit": [
{
- "name": "ZipFuseTest"
- },
- {
- "name": "apkdmverity.test"
- },
- {
- "name": "authfs_device_test_src_lib"
- },
- {
- "name": "diced_open_dice_cbor_test"
- },
- {
- "name": "diced_sample_inputs_test"
- },
- {
- "name": "diced_test"
- },
- {
- "name": "diced_utils_test"
- },
- {
- "name": "diced_vendor_test"
- },
- {
- "name": "doh_unit_test"
- },
- {
- "name": "keystore2_crypto_test_rust"
- },
- {
- "name": "keystore2_selinux_concurrency_test"
- },
- {
- "name": "keystore2_selinux_test"
+ "name": "anyhow_device_test_tests_test_repr"
},
{
"name": "keystore2_test"
},
{
- "name": "keystore2_test_utils_test"
- },
- {
- "name": "keystore2_vintf_test"
- },
- {
- "name": "legacykeystore_test"
+ "name": "anyhow_device_test_tests_test_context"
},
{
- "name": "libapkverify.integration_test"
+ "name": "libsqlite3-sys_device_test_src_lib"
},
{
- "name": "libapkverify.test"
- },
- {
- "name": "libcert_request_validator_tests"
- },
- {
- "name": "librustutils_test"
- },
- {
- "name": "microdroid_manager_test"
- },
- {
- "name": "virtualizationservice_device_test"
- }
- ],
- "presubmit-rust": [
- {
- "name": "ZipFuseTest"
- },
- {
- "name": "apkdmverity.test"
- },
- {
- "name": "authfs_device_test_src_lib"
- },
- {
- "name": "diced_open_dice_cbor_test"
- },
- {
- "name": "diced_sample_inputs_test"
- },
- {
- "name": "diced_test"
- },
- {
- "name": "diced_utils_test"
- },
- {
- "name": "diced_vendor_test"
- },
- {
- "name": "doh_unit_test"
+ "name": "anyhow_device_test_tests_test_downcast"
},
{
"name": "keystore2_crypto_test_rust"
},
{
- "name": "keystore2_selinux_concurrency_test"
- },
- {
- "name": "keystore2_selinux_test"
- },
- {
- "name": "keystore2_test"
+ "name": "anyhow_device_test_tests_test_convert"
},
{
- "name": "keystore2_test_utils_test"
+ "name": "anyhow_device_test_tests_test_ffi"
},
{
- "name": "keystore2_vintf_test"
+ "name": "anyhow_device_test_tests_test_autotrait"
},
{
- "name": "legacykeystore_test"
+ "name": "anyhow_device_test_tests_test_macros"
},
{
- "name": "libapkverify.integration_test"
+ "name": "anyhow_device_test_tests_test_boxed"
},
{
- "name": "libapkverify.test"
+ "name": "anyhow_device_test_tests_test_chain"
},
{
- "name": "libcert_request_validator_tests"
+ "name": "anyhow_device_test_src_lib"
},
{
- "name": "librustutils_test"
+ "name": "anyhow_device_test_tests_test_source"
},
{
- "name": "microdroid_manager_test"
+ "name": "anyhow_device_test_tests_test_fmt"
},
{
- "name": "virtualizationservice_device_test"
+ "name": "keystore2_selinux_test"
}
]
}
diff --git a/cargo2android.json b/cargo2android.json
index 9a52406..9b5d982 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -1,15 +1,11 @@
{
"apex-available": [
"//apex_available:platform",
- "com.android.bluetooth",
- "com.android.compos",
"com.android.resolv",
- "com.android.uwb",
"com.android.virt"
],
"dependencies": true,
"device": true,
- "min-sdk-version": "29",
- "run": true,
- "vendor-available": true
+ "min_sdk_version": "29",
+ "run": true
}
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
deleted file mode 100644
index 20fe888..0000000
--- a/rust-toolchain.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[toolchain]
-components = ["rust-src"]
diff --git a/src/aserror.rs b/src/aserror.rs
index c036b7b..8290296 100644
--- a/src/aserror.rs
+++ b/src/aserror.rs
@@ -1,41 +1,33 @@
use std::error::Error;
-use std::panic::UnwindSafe;
-pub trait AsDynError<'a> {
- fn as_dyn_error(&self) -> &(dyn Error + 'a);
+pub trait AsDynError {
+ fn as_dyn_error(&self) -> &(dyn Error + 'static);
}
-impl<'a, T: Error + 'a> AsDynError<'a> for T {
+impl<T: Error + 'static> AsDynError for T {
#[inline]
- fn as_dyn_error(&self) -> &(dyn Error + 'a) {
+ fn as_dyn_error(&self) -> &(dyn Error + 'static) {
self
}
}
-impl<'a> AsDynError<'a> for dyn Error + 'a {
+impl AsDynError for dyn Error + 'static {
#[inline]
- fn as_dyn_error(&self) -> &(dyn Error + 'a) {
+ fn as_dyn_error(&self) -> &(dyn Error + 'static) {
self
}
}
-impl<'a> AsDynError<'a> for dyn Error + Send + 'a {
+impl AsDynError for dyn Error + Send + 'static {
#[inline]
- fn as_dyn_error(&self) -> &(dyn Error + 'a) {
+ fn as_dyn_error(&self) -> &(dyn Error + 'static) {
self
}
}
-impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a {
+impl AsDynError for dyn Error + Send + Sync + 'static {
#[inline]
- fn as_dyn_error(&self) -> &(dyn Error + 'a) {
- self
- }
-}
-
-impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
- #[inline]
- fn as_dyn_error(&self) -> &(dyn Error + 'a) {
+ fn as_dyn_error(&self) -> &(dyn Error + 'static) {
self
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 2fae25c..02941c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -161,22 +161,6 @@
//! # };
//! ```
//!
-//! - If a field is both a source (named `source`, or has `#[source]` or
-//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error
-//! trait's `backtrace()` method is forwarded to the source's backtrace.
-//!
-//! ```rust
-//! # const IGNORE: &str = stringify! {
-//! #[derive(Error, Debug)]
-//! pub enum MyError {
-//! Io {
-//! #[backtrace]
-//! source: io::Error,
-//! },
-//! }
-//! # };
-//! ```
-//!
//! - Errors may use `error(transparent)` to forward the source and Display
//! methods straight through to an underlying error without adding an
//! additional message. This would be appropriate for enums that need an
@@ -201,11 +185,7 @@
//!
//! [`anyhow`]: https://github.com/dtolnay/anyhow
-#![allow(
- // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421
- clippy::doc_markdown,
- clippy::module_name_repetitions,
-)]
+#![allow(clippy::module_name_repetitions)]
mod aserror;
mod display;
diff --git a/tests/test_backtrace.rs b/tests/test_backtrace.rs
index 42e37ca..09bc13d 100644
--- a/tests/test_backtrace.rs
+++ b/tests/test_backtrace.rs
@@ -7,15 +7,8 @@ use thiserror::Error;
pub struct Inner;
#[cfg(thiserror_nightly_testing)]
-#[derive(Error, Debug)]
-#[error("...")]
-pub struct InnerBacktrace {
- backtrace: std::backtrace::Backtrace,
-}
-
-#[cfg(thiserror_nightly_testing)]
pub mod structs {
- use super::{Inner, InnerBacktrace};
+ use super::Inner;
use std::backtrace::Backtrace;
use std::error::Error;
use std::sync::Arc;
@@ -59,14 +52,6 @@ pub mod structs {
#[derive(Error, Debug)]
#[error("...")]
- pub struct CombinedBacktraceFrom {
- #[from]
- #[backtrace]
- source: InnerBacktrace,
- }
-
- #[derive(Error, Debug)]
- #[error("...")]
pub struct OptBacktraceFrom {
#[from]
source: Inner,
@@ -108,11 +93,6 @@ pub mod structs {
let error = BacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());
- let error = CombinedBacktraceFrom::from(InnerBacktrace {
- backtrace: Backtrace::capture(),
- });
- assert!(error.backtrace().is_some());
-
let error = OptBacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());
@@ -123,7 +103,7 @@ pub mod structs {
#[cfg(thiserror_nightly_testing)]
pub mod enums {
- use super::{Inner, InnerBacktrace};
+ use super::Inner;
use std::backtrace::Backtrace;
use std::error::Error;
use std::sync::Arc;
@@ -174,16 +154,6 @@ pub mod enums {
}
#[derive(Error, Debug)]
- pub enum CombinedBacktraceFrom {
- #[error("...")]
- Test {
- #[from]
- #[backtrace]
- source: InnerBacktrace,
- },
- }
-
- #[derive(Error, Debug)]
pub enum OptBacktraceFrom {
#[error("...")]
Test {
@@ -230,11 +200,6 @@ pub mod enums {
let error = BacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());
- let error = CombinedBacktraceFrom::from(InnerBacktrace {
- backtrace: Backtrace::capture(),
- });
- assert!(error.backtrace().is_some());
-
let error = OptBacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());
diff --git a/tests/test_deprecated.rs b/tests/test_deprecated.rs
new file mode 100644
index 0000000..5524666
--- /dev/null
+++ b/tests/test_deprecated.rs
@@ -0,0 +1,10 @@
+#![deny(deprecated, clippy::all, clippy::pedantic)]
+
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+pub enum Error {
+ #[deprecated]
+ #[error("...")]
+ Deprecated,
+}
diff --git a/tests/test_from.rs b/tests/test_from.rs
index a25ce35..e8f0161 100644
--- a/tests/test_from.rs
+++ b/tests/test_from.rs
@@ -12,21 +12,10 @@ pub struct ErrorStruct {
#[derive(Error, Debug)]
#[error("...")]
-pub struct ErrorStructOptional {
- #[from]
- source: Option<io::Error>,
-}
-
-#[derive(Error, Debug)]
-#[error("...")]
pub struct ErrorTuple(#[from] io::Error);
#[derive(Error, Debug)]
#[error("...")]
-pub struct ErrorTupleOptional(#[from] Option<io::Error>);
-
-#[derive(Error, Debug)]
-#[error("...")]
pub enum ErrorEnum {
Test {
#[from]
@@ -36,15 +25,6 @@ pub enum ErrorEnum {
#[derive(Error, Debug)]
#[error("...")]
-pub enum ErrorEnumOptional {
- Test {
- #[from]
- source: Option<io::Error>,
- },
-}
-
-#[derive(Error, Debug)]
-#[error("...")]
pub enum Many {
Any(#[from] anyhow::Error),
Io(#[from] io::Error),
@@ -55,10 +35,7 @@ fn assert_impl<T: From<io::Error>>() {}
#[test]
fn test_from() {
assert_impl::<ErrorStruct>();
- assert_impl::<ErrorStructOptional>();
assert_impl::<ErrorTuple>();
- assert_impl::<ErrorTupleOptional>();
assert_impl::<ErrorEnum>();
- assert_impl::<ErrorEnumOptional>();
assert_impl::<Many>();
}
diff --git a/tests/test_generics.rs b/tests/test_generics.rs
deleted file mode 100644
index f5e1de2..0000000
--- a/tests/test_generics.rs
+++ /dev/null
@@ -1,161 +0,0 @@
-#![deny(clippy::all, clippy::pedantic)]
-
-use std::fmt::{self, Debug, Display};
-use thiserror::Error;
-
-pub struct NoFormat;
-
-#[derive(Debug)]
-pub struct DebugOnly;
-
-pub struct DisplayOnly;
-
-impl Display for DisplayOnly {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("display only")
- }
-}
-
-#[derive(Debug)]
-pub struct DebugAndDisplay;
-
-impl Display for DebugAndDisplay {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("debug and display")
- }
-}
-
-// Should expand to:
-//
-// impl<E> Display for EnumDebugField<E>
-// where
-// E: Debug;
-//
-// impl<E> Error for EnumDebugField<E>
-// where
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-pub enum EnumDebugGeneric<E> {
- #[error("{0:?}")]
- FatalError(E),
-}
-
-// Should expand to:
-//
-// impl<E> Display for EnumFromGeneric<E>;
-//
-// impl<E> Error for EnumFromGeneric<E>
-// where
-// EnumDebugGeneric<E>: Error + 'static,
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-pub enum EnumFromGeneric<E> {
- #[error("enum from generic")]
- Source(#[from] EnumDebugGeneric<E>),
-}
-
-// Should expand to:
-//
-// impl<HasDisplay, HasDebug, HasNeither> Display
-// for EnumCompound<HasDisplay, HasDebug, HasNeither>
-// where
-// HasDisplay: Display,
-// HasDebug: Debug;
-//
-// impl<HasDisplay, HasDebug, HasNeither> Error
-// for EnumCompound<HasDisplay, HasDebug, HasNeither>
-// where
-// Self: Debug + Display;
-//
-#[derive(Error)]
-pub enum EnumCompound<HasDisplay, HasDebug, HasNeither> {
- #[error("{0} {1:?}")]
- DisplayDebug(HasDisplay, HasDebug),
- #[error("{0}")]
- Display(HasDisplay, HasNeither),
- #[error("{1:?}")]
- Debug(HasNeither, HasDebug),
-}
-
-impl<HasDisplay, HasDebug, HasNeither> Debug for EnumCompound<HasDisplay, HasDebug, HasNeither> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("EnumCompound")
- }
-}
-
-#[test]
-fn test_display_enum_compound() {
- let mut instance: EnumCompound<DisplayOnly, DebugOnly, NoFormat>;
-
- instance = EnumCompound::DisplayDebug(DisplayOnly, DebugOnly);
- assert_eq!(format!("{}", instance), "display only DebugOnly");
-
- instance = EnumCompound::Display(DisplayOnly, NoFormat);
- assert_eq!(format!("{}", instance), "display only");
-
- instance = EnumCompound::Debug(NoFormat, DebugOnly);
- assert_eq!(format!("{}", instance), "DebugOnly");
-}
-
-// Should expand to:
-//
-// impl<E> Display for EnumTransparentGeneric<E>
-// where
-// E: Display;
-//
-// impl<E> Error for EnumTransparentGeneric<E>
-// where
-// E: Error,
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-pub enum EnumTransparentGeneric<E> {
- #[error(transparent)]
- Other(E),
-}
-
-// Should expand to:
-//
-// impl<E> Display for StructDebugGeneric<E>
-// where
-// E: Debug;
-//
-// impl<E> Error for StructDebugGeneric<E>
-// where
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-#[error("{underlying:?}")]
-pub struct StructDebugGeneric<E> {
- pub underlying: E,
-}
-
-// Should expand to:
-//
-// impl<E> Error for StructFromGeneric<E>
-// where
-// StructDebugGeneric<E>: Error + 'static,
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-pub struct StructFromGeneric<E> {
- #[from]
- pub source: StructDebugGeneric<E>,
-}
-
-// Should expand to:
-//
-// impl<E> Display for StructTransparentGeneric<E>
-// where
-// E: Display;
-//
-// impl<E> Error for StructTransparentGeneric<E>
-// where
-// E: Error,
-// Self: Debug + Display;
-//
-#[derive(Error, Debug)]
-#[error(transparent)]
-pub struct StructTransparentGeneric<E>(E);
diff --git a/tests/test_source.rs b/tests/test_source.rs
index ab16097..860e727 100644
--- a/tests/test_source.rs
+++ b/tests/test_source.rs
@@ -60,8 +60,4 @@ macro_rules! error_from_macro {
}
// Test that we generate impls with the proper hygiene
-#[rustfmt::skip]
-error_from_macro! {
- #[error("Something")]
- Variant(#[from] io::Error)
-}
+error_from_macro!(#[error("Something")] Variant(#[from] io::Error));
diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs
index 84d7c91..b862b25 100644
--- a/tests/test_transparent.rs
+++ b/tests/test_transparent.rs
@@ -57,24 +57,3 @@ fn test_anyhow() {
assert_eq!("outer", error.to_string());
assert_eq!("inner", error.source().unwrap().to_string());
}
-
-#[test]
-fn test_non_static() {
- #[derive(Error, Debug)]
- #[error(transparent)]
- struct Error<'a> {
- inner: ErrorKind<'a>,
- }
-
- #[derive(Error, Debug)]
- enum ErrorKind<'a> {
- #[error("unexpected token: {:?}", token)]
- Unexpected { token: &'a str },
- }
-
- let error = Error {
- inner: ErrorKind::Unexpected { token: "error" },
- };
- assert_eq!("unexpected token: \"error\"", error.to_string());
- assert!(error.source().is_none());
-}
diff --git a/tests/ui/bad-field-attr.stderr b/tests/ui/bad-field-attr.stderr
index 5fb5744..ecc4702 100644
--- a/tests/ui/bad-field-attr.stderr
+++ b/tests/ui/bad-field-attr.stderr
@@ -1,5 +1,5 @@
error: #[error(transparent)] needs to go outside the enum or struct, not on an individual field
- --> tests/ui/bad-field-attr.rs:5:18
+ --> $DIR/bad-field-attr.rs:5:18
|
5 | pub struct Error(#[error(transparent)] std::io::Error);
| ^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/concat-display.stderr b/tests/ui/concat-display.stderr
index 6ab4048..df1e19a 100644
--- a/tests/ui/concat-display.stderr
+++ b/tests/ui/concat-display.stderr
@@ -1,5 +1,5 @@
error: expected string literal
- --> tests/ui/concat-display.rs:8:17
+ --> $DIR/concat-display.rs:8:17
|
8 | #[error(concat!("invalid ", $what))]
| ^^^^^^
@@ -7,4 +7,4 @@ error: expected string literal
13 | error_type!(Error, "foo");
| -------------------------- in this macro invocation
|
- = note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/duplicate-enum-source.stderr b/tests/ui/duplicate-enum-source.stderr
index 4a4b2d3..55d81be 100644
--- a/tests/ui/duplicate-enum-source.stderr
+++ b/tests/ui/duplicate-enum-source.stderr
@@ -1,5 +1,5 @@
error: duplicate #[source] attribute
- --> tests/ui/duplicate-enum-source.rs:8:9
+ --> $DIR/duplicate-enum-source.rs:8:9
|
8 | #[source]
| ^^^^^^^^^
diff --git a/tests/ui/duplicate-fmt.stderr b/tests/ui/duplicate-fmt.stderr
index 532b16b..3206640 100644
--- a/tests/ui/duplicate-fmt.stderr
+++ b/tests/ui/duplicate-fmt.stderr
@@ -1,5 +1,5 @@
error: only one #[error(...)] attribute is allowed
- --> tests/ui/duplicate-fmt.rs:5:1
+ --> $DIR/duplicate-fmt.rs:5:1
|
5 | #[error("...")]
| ^^^^^^^^^^^^^^^
diff --git a/tests/ui/duplicate-struct-source.stderr b/tests/ui/duplicate-struct-source.stderr
index c8de574..76fc6f5 100644
--- a/tests/ui/duplicate-struct-source.stderr
+++ b/tests/ui/duplicate-struct-source.stderr
@@ -1,5 +1,5 @@
error: duplicate #[source] attribute
- --> tests/ui/duplicate-struct-source.rs:7:5
+ --> $DIR/duplicate-struct-source.rs:7:5
|
7 | #[source]
| ^^^^^^^^^
diff --git a/tests/ui/duplicate-transparent.stderr b/tests/ui/duplicate-transparent.stderr
index a830879..c963475 100644
--- a/tests/ui/duplicate-transparent.stderr
+++ b/tests/ui/duplicate-transparent.stderr
@@ -1,5 +1,5 @@
error: duplicate #[error(transparent)] attribute
- --> tests/ui/duplicate-transparent.rs:5:1
+ --> $DIR/duplicate-transparent.rs:5:1
|
5 | #[error(transparent)]
| ^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/from-not-source.stderr b/tests/ui/from-not-source.stderr
index 9713601..b656c8e 100644
--- a/tests/ui/from-not-source.stderr
+++ b/tests/ui/from-not-source.stderr
@@ -1,5 +1,5 @@
error: #[from] is only supported on the source field, not any other field
- --> tests/ui/from-not-source.rs:7:5
+ --> $DIR/from-not-source.rs:7:5
|
7 | #[from]
| ^^^^^^^
diff --git a/tests/ui/lifetime.stderr b/tests/ui/lifetime.stderr
index 8b58136..5f86fa0 100644
--- a/tests/ui/lifetime.stderr
+++ b/tests/ui/lifetime.stderr
@@ -1,11 +1,11 @@
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
- --> tests/ui/lifetime.rs:6:26
+ --> $DIR/lifetime.rs:6:26
|
6 | struct Error<'a>(#[from] Inner<'a>);
| ^^^^^^^^^
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
- --> tests/ui/lifetime.rs:15:17
+ --> $DIR/lifetime.rs:15:17
|
15 | Foo(#[from] Generic<&'a str>),
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/missing-fmt.stderr b/tests/ui/missing-fmt.stderr
index c0be373..1d21b1b 100644
--- a/tests/ui/missing-fmt.stderr
+++ b/tests/ui/missing-fmt.stderr
@@ -1,5 +1,5 @@
error: missing #[error("...")] display attribute
- --> tests/ui/missing-fmt.rs:7:5
+ --> $DIR/missing-fmt.rs:7:5
|
7 | B(usize),
| ^^^^^^^^
diff --git a/tests/ui/no-display.stderr b/tests/ui/no-display.stderr
index e6a52f5..8af2452 100644
--- a/tests/ui/no-display.stderr
+++ b/tests/ui/no-display.stderr
@@ -1,23 +1,12 @@
error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its trait bounds were not satisfied
- --> tests/ui/no-display.rs:7:9
- |
-4 | struct NoDisplay;
- | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display`
+ --> $DIR/no-display.rs:7:9
+ |
+4 | struct NoDisplay;
+ | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display`
...
-7 | #[error("thread: {thread}")]
- | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `NoDisplay: std::fmt::Display`
- which is required by `&NoDisplay: DisplayAsDisplay`
-note: the following trait must be implemented
- --> $RUST/core/src/fmt/mod.rs
- |
- | / pub trait Display {
- | | /// Formats the value using the given formatter.
- | | ///
- | | /// # Examples
-... |
- | | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
- | | }
- | |_^
+7 | #[error("thread: {thread}")]
+ | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `NoDisplay: std::fmt::Display`
+ which is required by `&NoDisplay: DisplayAsDisplay`
diff --git a/tests/ui/source-enum-not-error.stderr b/tests/ui/source-enum-not-error.stderr
index d01cba5..2bf7aea 100644
--- a/tests/ui/source-enum-not-error.stderr
+++ b/tests/ui/source-enum-not-error.stderr
@@ -1,28 +1,17 @@
error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied
- --> tests/ui/source-enum-not-error.rs:10:9
- |
-4 | pub struct NotError;
- | --------------------
- | |
- | doesn't satisfy `NotError: AsDynError`
- | doesn't satisfy `NotError: std::error::Error`
+ --> $DIR/source-enum-not-error.rs:10:9
+ |
+4 | pub struct NotError;
+ | --------------------
+ | |
+ | doesn't satisfy `NotError: AsDynError`
+ | doesn't satisfy `NotError: std::error::Error`
...
-10 | source: NotError,
- | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `NotError: std::error::Error`
- which is required by `NotError: AsDynError`
- `&NotError: std::error::Error`
- which is required by `&NotError: AsDynError`
-note: the following trait must be implemented
- --> $RUST/std/src/error.rs
- |
- | / pub trait Error: Debug + Display {
- | | /// The lower-level source of this error, if any.
- | | ///
- | | /// # Examples
-... |
- | | }
- | | }
- | |_^
+10 | source: NotError,
+ | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `NotError: std::error::Error`
+ which is required by `NotError: AsDynError`
+ `&NotError: std::error::Error`
+ which is required by `&NotError: AsDynError`
diff --git a/tests/ui/source-struct-not-error.stderr b/tests/ui/source-struct-not-error.stderr
index be1331a..7a2c0fe 100644
--- a/tests/ui/source-struct-not-error.stderr
+++ b/tests/ui/source-struct-not-error.stderr
@@ -1,27 +1,16 @@
error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied
- --> tests/ui/source-struct-not-error.rs:9:5
- |
-4 | struct NotError;
- | ----------------
- | |
- | method `as_dyn_error` not found for this
- | doesn't satisfy `NotError: AsDynError`
- | doesn't satisfy `NotError: std::error::Error`
+ --> $DIR/source-struct-not-error.rs:9:5
+ |
+4 | struct NotError;
+ | ----------------
+ | |
+ | method `as_dyn_error` not found for this
+ | doesn't satisfy `NotError: AsDynError`
+ | doesn't satisfy `NotError: std::error::Error`
...
-9 | source: NotError,
- | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `NotError: std::error::Error`
- which is required by `NotError: AsDynError`
-note: the following trait must be implemented
- --> $RUST/std/src/error.rs
- |
- | / pub trait Error: Debug + Display {
- | | /// The lower-level source of this error, if any.
- | | ///
- | | /// # Examples
-... |
- | | }
- | | }
- | |_^
+9 | source: NotError,
+ | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `NotError: std::error::Error`
+ which is required by `NotError: AsDynError`
diff --git a/tests/ui/transparent-display.stderr b/tests/ui/transparent-display.stderr
index 54d958b..0148830 100644
--- a/tests/ui/transparent-display.stderr
+++ b/tests/ui/transparent-display.stderr
@@ -1,5 +1,5 @@
error: cannot have both #[error(transparent)] and a display attribute
- --> tests/ui/transparent-display.rs:5:1
+ --> $DIR/transparent-display.rs:5:1
|
5 | #[error("...")]
| ^^^^^^^^^^^^^^^
diff --git a/tests/ui/transparent-enum-many.stderr b/tests/ui/transparent-enum-many.stderr
index a9adfa5..0c409ef 100644
--- a/tests/ui/transparent-enum-many.stderr
+++ b/tests/ui/transparent-enum-many.stderr
@@ -1,5 +1,5 @@
error: #[error(transparent)] requires exactly one field
- --> tests/ui/transparent-enum-many.rs:5:5
+ --> $DIR/transparent-enum-many.rs:5:5
|
5 | / #[error(transparent)]
6 | | Other(anyhow::Error, String),
diff --git a/tests/ui/transparent-enum-source.stderr b/tests/ui/transparent-enum-source.stderr
index ccb9067..a4e6985 100644
--- a/tests/ui/transparent-enum-source.stderr
+++ b/tests/ui/transparent-enum-source.stderr
@@ -1,5 +1,5 @@
error: transparent variant can't contain #[source]
- --> tests/ui/transparent-enum-source.rs:6:11
+ --> $DIR/transparent-enum-source.rs:6:11
|
6 | Other(#[source] anyhow::Error),
| ^^^^^^^^^
diff --git a/tests/ui/transparent-struct-many.stderr b/tests/ui/transparent-struct-many.stderr
index c0e3806..102f0b3 100644
--- a/tests/ui/transparent-struct-many.stderr
+++ b/tests/ui/transparent-struct-many.stderr
@@ -1,5 +1,5 @@
error: #[error(transparent)] requires exactly one field
- --> tests/ui/transparent-struct-many.rs:4:1
+ --> $DIR/transparent-struct-many.rs:4:1
|
4 | #[error(transparent)]
| ^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/transparent-struct-source.stderr b/tests/ui/transparent-struct-source.stderr
index 3012ca3..16ea50b 100644
--- a/tests/ui/transparent-struct-source.stderr
+++ b/tests/ui/transparent-struct-source.stderr
@@ -1,5 +1,5 @@
error: transparent error struct can't contain #[source]
- --> tests/ui/transparent-struct-source.rs:5:18
+ --> $DIR/transparent-struct-source.rs:5:18
|
5 | pub struct Error(#[source] anyhow::Error);
| ^^^^^^^^^
diff --git a/tests/ui/unexpected-field-fmt.stderr b/tests/ui/unexpected-field-fmt.stderr
index bf3c24d..42d80db 100644
--- a/tests/ui/unexpected-field-fmt.stderr
+++ b/tests/ui/unexpected-field-fmt.stderr
@@ -1,5 +1,5 @@
error: not expected here; the #[error(...)] attribute belongs on top of a struct or an enum variant
- --> tests/ui/unexpected-field-fmt.rs:6:9
+ --> $DIR/unexpected-field-fmt.rs:6:9
|
6 | #[error("...")]
| ^^^^^^^^^^^^^^^
diff --git a/tests/ui/unexpected-struct-source.stderr b/tests/ui/unexpected-struct-source.stderr
index 6f15841..f48d554 100644
--- a/tests/ui/unexpected-struct-source.stderr
+++ b/tests/ui/unexpected-struct-source.stderr
@@ -1,5 +1,5 @@
error: not expected here; the #[source] attribute belongs on a specific field
- --> tests/ui/unexpected-struct-source.rs:4:1
+ --> $DIR/unexpected-struct-source.rs:4:1
|
4 | #[source]
| ^^^^^^^^^
diff --git a/tests/ui/union.stderr b/tests/ui/union.stderr
index 3ec4d71..a378011 100644
--- a/tests/ui/union.stderr
+++ b/tests/ui/union.stderr
@@ -1,5 +1,5 @@
error: union as errors are not supported
- --> tests/ui/union.rs:4:1
+ --> $DIR/union.rs:4:1
|
4 | / pub union U {
5 | | msg: &'static str,