Files
rust/tests/run-make/duplicate-dependency/main.stderr
Martin Nordholts eeb7cb1b8a compiler: Hint at multiple crate versions if trait impl is for wrong ADT
If a user does e.g.

    impl From<Bar> for foo::Foo

and get a compilation error about that `From<Bar>` is not implemented
for `Foo`, check if multiple versions of the crate with `Foo` is present
in the dependency graph. If so, give a hint about it.

I encountered this case in the wild and didn't realize I had multiple
versions of a crate in my dependency graph. So I was a bit confused at
first. This fix will make life easier for others.
2025-10-06 06:21:45 +02:00

25 lines
893 B
Plaintext

error[E0277]: the trait bound `re_export_foo::foo::Foo: From<Bar>` is not satisfied
--> main.rs:14:29
|
LL | re_export_foo::into_foo(Bar);
| ----------------------- ^^^ the trait `From<Bar>` is not implemented for `re_export_foo::foo::Foo`
| |
| required by a bound introduced by this call
|
help: item with same name found
--> $DIR/foo-v1.rs:1:1
|
LL | pub struct Foo;
| ^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `foo` are being used?
= note: required for `Bar` to implement `Into<re_export_foo::foo::Foo>`
note: required by a bound in `into_foo`
--> $DIR/re-export-foo.rs:3:25
|
LL | pub fn into_foo(_: impl Into<foo::Foo>) {}
| ^^^^^^^^^^^^^^ required by this bound in `into_foo`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.