```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
--> replaced
|
LL | fn main() -> Result<(), Error> {
| ----------------- expected `dependency::Error` because of this
...
LL | Err(Error2)?;
| -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
| |
| this can't be annotated with `?` because it has type `Result<_, Error2>`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
but trait `From<()>` is implemented for it
--> replaced
|
LL | impl From<()> for Error {
| ^^^^^^^^^^^^^^^^^^^^^^^
= help: for that trait implementation, expected `()`, found `Error2`
= note: there are multiple different versions of crate `dependency` in the dependency graph
= help: you can use `cargo tree` to explore your dependency tree
```
The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.
20 lines
514 B
Rust
20 lines
514 B
Rust
extern crate dep_2_reexport;
|
|
extern crate dependency;
|
|
use dep_2_reexport::{Error2, OtherType, Trait2, Type};
|
|
use dependency::{Error, OtherError, Trait, do_something, do_something_trait, do_something_type};
|
|
|
|
fn main() -> Result<(), Error> {
|
|
do_something(Type);
|
|
Type.foo();
|
|
Type::bar();
|
|
do_something(OtherType);
|
|
do_something_type(Type);
|
|
do_something_trait(Box::new(Type) as Box<dyn Trait2>);
|
|
Err(Error2)?;
|
|
Ok(())
|
|
}
|
|
|
|
fn foo() -> Result<(), OtherError> {
|
|
Err(Error2)?;
|
|
Ok(())
|
|
}
|