summaryrefslogtreecommitdiffstats
path: root/vendor/thiserror/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/thiserror/tests')
-rw-r--r--vendor/thiserror/tests/test_backtrace.rs46
-rw-r--r--vendor/thiserror/tests/test_deprecated.rs10
-rw-r--r--vendor/thiserror/tests/ui/source-enum-not-error.stderr6
-rw-r--r--vendor/thiserror/tests/ui/source-struct-not-error.stderr4
4 files changed, 61 insertions, 5 deletions
diff --git a/vendor/thiserror/tests/test_backtrace.rs b/vendor/thiserror/tests/test_backtrace.rs
index 052c6f481..43f68b8b7 100644
--- a/vendor/thiserror/tests/test_backtrace.rs
+++ b/vendor/thiserror/tests/test_backtrace.rs
@@ -21,6 +21,7 @@ pub mod structs {
use super::{Inner, InnerBacktrace};
use std::any;
use std::backtrace::Backtrace;
+ use std::error::Error;
use std::sync::Arc;
use thiserror::Error;
@@ -86,6 +87,20 @@ pub mod structs {
backtrace: Arc<Backtrace>,
}
+ #[derive(Error, Debug)]
+ #[error("...")]
+ pub struct AnyhowBacktrace {
+ #[backtrace]
+ source: anyhow::Error,
+ }
+
+ #[derive(Error, Debug)]
+ #[error("...")]
+ pub struct BoxDynErrorBacktrace {
+ #[backtrace]
+ source: Box<dyn Error>,
+ }
+
#[test]
fn test_backtrace() {
let error = PlainBacktrace {
@@ -121,6 +136,37 @@ pub mod structs {
let error = ArcBacktraceFrom::from(Inner);
assert!(any::request_ref::<Backtrace>(&error).is_some());
+
+ let error = AnyhowBacktrace {
+ source: anyhow::Error::msg("..."),
+ };
+ assert!(any::request_ref::<Backtrace>(&error).is_some());
+
+ let error = BoxDynErrorBacktrace {
+ source: Box::new(PlainBacktrace {
+ backtrace: Backtrace::capture(),
+ }),
+ };
+ assert!(any::request_ref::<Backtrace>(&error).is_some());
+ }
+
+ // https://github.com/dtolnay/thiserror/issues/185 -- std::error::Error and
+ // std::any::Provide both have a method called 'provide', so directly
+ // calling it from generated code could be ambiguous.
+ #[test]
+ fn test_provide_name_collision() {
+ use std::any::Provider;
+
+ #[derive(Error, Debug)]
+ #[error("...")]
+ struct MyError {
+ #[source]
+ #[backtrace]
+ x: std::io::Error,
+ }
+
+ let _: dyn Error;
+ let _: dyn Provider;
}
}
diff --git a/vendor/thiserror/tests/test_deprecated.rs b/vendor/thiserror/tests/test_deprecated.rs
new file mode 100644
index 000000000..5524666ab
--- /dev/null
+++ b/vendor/thiserror/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/vendor/thiserror/tests/ui/source-enum-not-error.stderr b/vendor/thiserror/tests/ui/source-enum-not-error.stderr
index da10c6e77..29ee54600 100644
--- a/vendor/thiserror/tests/ui/source-enum-not-error.stderr
+++ b/vendor/thiserror/tests/ui/source-enum-not-error.stderr
@@ -4,7 +4,7 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but it
4 | pub struct NotError;
| -------------------
| |
- | doesn't satisfy `NotError: AsDynError`
+ | doesn't satisfy `NotError: AsDynError<'_>`
| doesn't satisfy `NotError: std::error::Error`
...
10 | source: NotError,
@@ -12,9 +12,9 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but it
|
= note: the following trait bounds were not satisfied:
`NotError: std::error::Error`
- which is required by `NotError: AsDynError`
+ which is required by `NotError: AsDynError<'_>`
`&NotError: std::error::Error`
- which is required by `&NotError: AsDynError`
+ which is required by `&NotError: AsDynError<'_>`
note: the following trait must be implemented
--> $RUST/core/src/error.rs
|
diff --git a/vendor/thiserror/tests/ui/source-struct-not-error.stderr b/vendor/thiserror/tests/ui/source-struct-not-error.stderr
index cc0e67aca..efa40281d 100644
--- a/vendor/thiserror/tests/ui/source-struct-not-error.stderr
+++ b/vendor/thiserror/tests/ui/source-struct-not-error.stderr
@@ -5,7 +5,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its tr
| ---------------
| |
| method `as_dyn_error` not found for this struct
- | doesn't satisfy `NotError: AsDynError`
+ | doesn't satisfy `NotError: AsDynError<'_>`
| doesn't satisfy `NotError: std::error::Error`
...
9 | source: NotError,
@@ -13,7 +13,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its tr
|
= note: the following trait bounds were not satisfied:
`NotError: std::error::Error`
- which is required by `NotError: AsDynError`
+ which is required by `NotError: AsDynError<'_>`
note: the following trait must be implemented
--> $RUST/core/src/error.rs
|