diff --git a/tests/ui/multiple-provide.rs b/tests/ui/multiple-provide.rs new file mode 100644 index 0000000..dc2c52b --- /dev/null +++ b/tests/ui/multiple-provide.rs @@ -0,0 +1,19 @@ +#![feature(error_generic_member_access, provide_any)] + +use thiserror::Error; +use std::any::Provider; +use std::error::Error; + +// FIXME: this should work. https://github.com/dtolnay/thiserror/issues/185 +#[derive(Error, Debug)] +#[error("...")] +struct MyError { + #[source] + #[backtrace] + x: std::io::Error, +} + +fn main() { + let _: dyn Error; + let _: dyn Provider; +} diff --git a/tests/ui/multiple-provide.stderr b/tests/ui/multiple-provide.stderr new file mode 100644 index 0000000..14dcffa --- /dev/null +++ b/tests/ui/multiple-provide.stderr @@ -0,0 +1,16 @@ +error[E0034]: multiple applicable items in scope + --> tests/ui/multiple-provide.rs:13:5 + | +13 | x: std::io::Error, + | ^ multiple `provide` found + | + = note: candidate #1 is defined in an impl of the trait `Provider` for the type `E` + = note: candidate #2 is defined in an impl of the trait `std::error::Error` for the type `std::io::Error` +help: disambiguate the associated function for candidate #1 + | +13 | Provider::provide(&x, Error): std::io::Error, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +help: disambiguate the associated function for candidate #2 + | +13 | std::error::Error::provide(&x, Error): std::io::Error, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~