Skip to content

Commit 21198c9

Browse files
committed
Move multiple-provide test into test_backtrace
Currently fails with: error[E0034]: multiple applicable items in scope --> tests/test_backtrace.rs:165:13 | 165 | 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 | 165 | Provider::provide(&x, Error): std::io::Error, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help: disambiguate the associated function for candidate #2 | 165 | std::error::Error::provide(&x, Error): std::io::Error, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent 37442be commit 21198c9

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

Diff for: tests/test_backtrace.rs

+19
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,25 @@ pub mod structs {
149149
};
150150
assert!(any::request_ref::<Backtrace>(&error).is_some());
151151
}
152+
153+
// https://github.com/dtolnay/thiserror/issues/185 -- std::error::Error and
154+
// std::any::Provide both have a method called 'provide', so directly
155+
// calling it from generated code could be ambiguous.
156+
#[test]
157+
fn test_provide_name_collision() {
158+
use std::any::Provider;
159+
160+
#[derive(Error, Debug)]
161+
#[error("...")]
162+
struct MyError {
163+
#[source]
164+
#[backtrace]
165+
x: std::io::Error,
166+
}
167+
168+
let _: dyn Error;
169+
let _: dyn Provider;
170+
}
152171
}
153172

154173
#[cfg(thiserror_nightly_testing)]

Diff for: tests/ui/multiple-provide.rs

-19
This file was deleted.

Diff for: tests/ui/multiple-provide.stderr

-16
This file was deleted.

0 commit comments

Comments
 (0)