From 8b663dc3ea96d4a64ce8f55ec8fb6ab543e69b4a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 4 Nov 2024 23:47:27 -0500 Subject: [PATCH] Add ui test of colliding From impls --- tests/ui/same-from-type.rs | 11 +++++++++++ tests/ui/same-from-type.stderr | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 tests/ui/same-from-type.rs create mode 100644 tests/ui/same-from-type.stderr diff --git a/tests/ui/same-from-type.rs b/tests/ui/same-from-type.rs new file mode 100644 index 0000000..bc32b07 --- /dev/null +++ b/tests/ui/same-from-type.rs @@ -0,0 +1,11 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[error("failed to open")] + OpenFile(#[from] std::io::Error), + #[error("failed to close")] + CloseFIle(#[from] std::io::Error), +} + +fn main() {} diff --git a/tests/ui/same-from-type.stderr b/tests/ui/same-from-type.stderr new file mode 100644 index 0000000..1e33385 --- /dev/null +++ b/tests/ui/same-from-type.stderr @@ -0,0 +1,5 @@ +error: cannot derive From because another variant has the same source type + --> tests/ui/same-from-type.rs:8:15 + | +8 | CloseFIle(#[from] std::io::Error), + | ^^^^^^^^^^^^^^^^^^^^^^