diff --git a/tests/test_backtrace.rs b/tests/test_backtrace.rs index d197447..43f68b8 100644 --- a/tests/test_backtrace.rs +++ b/tests/test_backtrace.rs @@ -149,6 +149,25 @@ pub mod structs { }; assert!(any::request_ref::(&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; + } } #[cfg(thiserror_nightly_testing)] diff --git a/tests/ui/multiple-provide.rs b/tests/ui/multiple-provide.rs deleted file mode 100644 index dc2c52b..0000000 --- a/tests/ui/multiple-provide.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![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 deleted file mode 100644 index 14dcffa..0000000 --- a/tests/ui/multiple-provide.stderr +++ /dev/null @@ -1,16 +0,0 @@ -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, - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~