```
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.
40 lines
700 B
Rust
40 lines
700 B
Rust
#![crate_name = "dependency"]
|
|
#![crate_type = "rlib"]
|
|
pub struct Type;
|
|
pub trait Trait {
|
|
fn foo(&self);
|
|
fn bar();
|
|
}
|
|
pub trait Trait2 {}
|
|
impl Trait2 for Type {}
|
|
impl Trait for Type {
|
|
fn foo(&self) {}
|
|
fn bar() {}
|
|
}
|
|
pub fn do_something<X: Trait>(_: X) {}
|
|
pub fn do_something_type(_: Type) {}
|
|
pub fn do_something_trait(_: Box<dyn Trait2>) {}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error;
|
|
|
|
impl From<()> for Error {
|
|
fn from(t: ()) -> Error {
|
|
Error
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct OtherError;
|
|
|
|
impl From<()> for OtherError {
|
|
fn from(_: ()) -> OtherError {
|
|
OtherError
|
|
}
|
|
}
|
|
|
|
impl From<i32> for OtherError {
|
|
fn from(_: i32) -> OtherError {
|
|
OtherError
|
|
}
|
|
}
|