Skip to content

Commit

Permalink
Move multiple-provide test into test_backtrace
Browse files Browse the repository at this point in the history
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,
        |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Loading branch information
dtolnay committed Sep 13, 2022
1 parent 37442be commit 21198c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 35 deletions.
19 changes: 19 additions & 0 deletions tests/test_backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ pub mod structs {
};
assert!(any::request_ref::<Backtrace>(&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)]
Expand Down
19 changes: 0 additions & 19 deletions tests/ui/multiple-provide.rs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/ui/multiple-provide.stderr

This file was deleted.

0 comments on commit 21198c9

Please sign in to comment.