diff --git a/tests/ui/duplicate-transparent.rs b/tests/ui/duplicate-transparent.rs new file mode 100644 index 0000000..49c0e46 --- /dev/null +++ b/tests/ui/duplicate-transparent.rs @@ -0,0 +1,8 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +#[error(transparent)] +pub struct Error(anyhow::Error); + +fn main() {} diff --git a/tests/ui/duplicate-transparent.stderr b/tests/ui/duplicate-transparent.stderr new file mode 100644 index 0000000..c963475 --- /dev/null +++ b/tests/ui/duplicate-transparent.stderr @@ -0,0 +1,5 @@ +error: duplicate #[error(transparent)] attribute + --> $DIR/duplicate-transparent.rs:5:1 + | +5 | #[error(transparent)] + | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transparent-display.rs b/tests/ui/transparent-display.rs new file mode 100644 index 0000000..2a59f18 --- /dev/null +++ b/tests/ui/transparent-display.rs @@ -0,0 +1,8 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +#[error("...")] +pub struct Error(anyhow::Error); + +fn main() {} diff --git a/tests/ui/transparent-display.stderr b/tests/ui/transparent-display.stderr new file mode 100644 index 0000000..0148830 --- /dev/null +++ b/tests/ui/transparent-display.stderr @@ -0,0 +1,5 @@ +error: cannot have both #[error(transparent)] and a display attribute + --> $DIR/transparent-display.rs:5:1 + | +5 | #[error("...")] + | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/transparent-enum-many.rs b/tests/ui/transparent-enum-many.rs new file mode 100644 index 0000000..e2a73a4 --- /dev/null +++ b/tests/ui/transparent-enum-many.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[error(transparent)] + Other(anyhow::Error, String), +} + +fn main() {} diff --git a/tests/ui/transparent-enum-many.stderr b/tests/ui/transparent-enum-many.stderr new file mode 100644 index 0000000..0c409ef --- /dev/null +++ b/tests/ui/transparent-enum-many.stderr @@ -0,0 +1,6 @@ +error: #[error(transparent)] requires exactly one field + --> $DIR/transparent-enum-many.rs:5:5 + | +5 | / #[error(transparent)] +6 | | Other(anyhow::Error, String), + | |________________________________^ diff --git a/tests/ui/transparent-enum-source.rs b/tests/ui/transparent-enum-source.rs new file mode 100644 index 0000000..3849f66 --- /dev/null +++ b/tests/ui/transparent-enum-source.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[error(transparent)] + Other(#[source] anyhow::Error), +} + +fn main() {} diff --git a/tests/ui/transparent-enum-source.stderr b/tests/ui/transparent-enum-source.stderr new file mode 100644 index 0000000..a4e6985 --- /dev/null +++ b/tests/ui/transparent-enum-source.stderr @@ -0,0 +1,5 @@ +error: transparent variant can't contain #[source] + --> $DIR/transparent-enum-source.rs:6:11 + | +6 | Other(#[source] anyhow::Error), + | ^^^^^^^^^ diff --git a/tests/ui/transparent-struct-many.rs b/tests/ui/transparent-struct-many.rs new file mode 100644 index 0000000..18f2466 --- /dev/null +++ b/tests/ui/transparent-struct-many.rs @@ -0,0 +1,10 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +pub struct Error { + inner: anyhow::Error, + what: String, +} + +fn main() {} diff --git a/tests/ui/transparent-struct-many.stderr b/tests/ui/transparent-struct-many.stderr new file mode 100644 index 0000000..102f0b3 --- /dev/null +++ b/tests/ui/transparent-struct-many.stderr @@ -0,0 +1,5 @@ +error: #[error(transparent)] requires exactly one field + --> $DIR/transparent-struct-many.rs:4:1 + | +4 | #[error(transparent)] + | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transparent-struct-source.rs b/tests/ui/transparent-struct-source.rs new file mode 100644 index 0000000..d4512c2 --- /dev/null +++ b/tests/ui/transparent-struct-source.rs @@ -0,0 +1,7 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +pub struct Error(#[source] anyhow::Error); + +fn main() {} diff --git a/tests/ui/transparent-struct-source.stderr b/tests/ui/transparent-struct-source.stderr new file mode 100644 index 0000000..16ea50b --- /dev/null +++ b/tests/ui/transparent-struct-source.stderr @@ -0,0 +1,5 @@ +error: transparent error struct can't contain #[source] + --> $DIR/transparent-struct-source.rs:5:18 + | +5 | pub struct Error(#[source] anyhow::Error); + | ^^^^^^^^^