-
Notifications
You must be signed in to change notification settings - Fork 13.8k
compiler: Hint at multiple crate versions if trait impl is for wrong ADT #146874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Enselic
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
Enselic:multiple-adt-versions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
I haven't compared the two PRs but CC open PR #144674 which also touches this function. |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Sep 23, 2025
tests/run-make/crate-loading: Rename source files for clarity For rust-lang#146874 I originally tried to extend the existing test **tests/run-make/crate-loading**. That didn't work out since adding a re-export of the entire crate significantly changes the emitted error messsage. I did put some effort into making that test easier to understand however, by renaming its files. (Since I was confused myself at first.) Let's save some time for future devs by doing just the renames. Further cleanups are possible, but that will change the blessed output, so let's not do that right now. r? `@jieyouxu` since you have the context of rust-lang#146874
Kobzol
added a commit
to Kobzol/rust
that referenced
this pull request
Sep 23, 2025
tests/run-make/crate-loading: Rename source files for clarity For rust-lang#146874 I originally tried to extend the existing test **tests/run-make/crate-loading**. That didn't work out since adding a re-export of the entire crate significantly changes the emitted error messsage. I did put some effort into making that test easier to understand however, by renaming its files. (Since I was confused myself at first.) Let's save some time for future devs by doing just the renames. Further cleanups are possible, but that will change the blessed output, so let's not do that right now. r? ``@jieyouxu`` since you have the context of rust-lang#146874
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Sep 23, 2025
tests/run-make/crate-loading: Rename source files for clarity For rust-lang#146874 I originally tried to extend the existing test **tests/run-make/crate-loading**. That didn't work out since adding a re-export of the entire crate significantly changes the emitted error messsage. I did put some effort into making that test easier to understand however, by renaming its files. (Since I was confused myself at first.) Let's save some time for future devs by doing just the renames. Further cleanups are possible, but that will change the blessed output, so let's not do that right now. r? ```@jieyouxu``` since you have the context of rust-lang#146874
rust-timer
added a commit
that referenced
this pull request
Sep 23, 2025
Rollup merge of #146875 - Enselic:better-file-names, r=jieyouxu tests/run-make/crate-loading: Rename source files for clarity For #146874 I originally tried to extend the existing test **tests/run-make/crate-loading**. That didn't work out since adding a re-export of the entire crate significantly changes the emitted error messsage. I did put some effort into making that test easier to understand however, by renaming its files. (Since I was confused myself at first.) Let's save some time for future devs by doing just the renames. Further cleanups are possible, but that will change the blessed output, so let's not do that right now. r? ```@jieyouxu``` since you have the context of #146874
Muscraft
pushed a commit
to Muscraft/rust
that referenced
this pull request
Sep 24, 2025
tests/run-make/crate-loading: Rename source files for clarity For rust-lang#146874 I originally tried to extend the existing test **tests/run-make/crate-loading**. That didn't work out since adding a re-export of the entire crate significantly changes the emitted error messsage. I did put some effort into making that test easier to understand however, by renaming its files. (Since I was confused myself at first.) Let's save some time for future devs by doing just the renames. Further cleanups are possible, but that will change the blessed output, so let's not do that right now. r? ```@jieyouxu``` since you have the context of rust-lang#146874
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-run-make
Area: port run-make Makefiles to rmake.rs
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a user does e.g.
and get a compilation error about that
From<Bar>
is not implemented forFoo
, check if multiple versions of the crate withFoo
is present in the dependency graph. If so, give a hint about it.Note that a test is added as a separate commit so it is easy to see what effect the fix has on the emitted error message.
This can be seen as a continuation of #124944.
I think this closes RUST-71693 but I haven't checked since it lacks a minimal reproducer. If this gets merged I'll ask that reporter if this fix works for them.
Real world example
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. For reference, here is what that looked like.
Click to expand
Before fix
After fix