aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-06-21 14:13:07 -0700
committerJoel Galenson <jgalenson@google.com>2021-06-21 14:13:07 -0700
commit933f15e068e3aaf37444484c2571f84aa799d221 (patch)
tree216ebc820efd102a5deafa7a05808242a1507523 /tests
parentb586767a9477acf89755b3fac1992933d9d20ffd (diff)
downloadthiserror-933f15e068e3aaf37444484c2571f84aa799d221.tar.gz
Upgrade rust/crates/thiserror to 1.0.25
Test: make Change-Id: If65cc840f54901ed2874343075cf7cb2b40f4323
Diffstat (limited to 'tests')
-rw-r--r--tests/test_source.rs6
-rw-r--r--tests/test_transparent.rs21
-rw-r--r--tests/ui/concat-display.stderr2
3 files changed, 27 insertions, 2 deletions
diff --git a/tests/test_source.rs b/tests/test_source.rs
index 860e727..ab16097 100644
--- a/tests/test_source.rs
+++ b/tests/test_source.rs
@@ -60,4 +60,8 @@ macro_rules! error_from_macro {
}
// Test that we generate impls with the proper hygiene
-error_from_macro!(#[error("Something")] Variant(#[from] io::Error));
+#[rustfmt::skip]
+error_from_macro! {
+ #[error("Something")]
+ Variant(#[from] io::Error)
+}
diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs
index b862b25..84d7c91 100644
--- a/tests/test_transparent.rs
+++ b/tests/test_transparent.rs
@@ -57,3 +57,24 @@ 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/concat-display.stderr b/tests/ui/concat-display.stderr
index df1e19a..a009145 100644
--- a/tests/ui/concat-display.stderr
+++ b/tests/ui/concat-display.stderr
@@ -7,4 +7,4 @@ error: expected string literal
13 | error_type!(Error, "foo");
| -------------------------- in this macro invocation
|
- = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)