-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
If two crates have the same name, distinguish them in rustc's output? #110926
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-crate-version-mismatch
Diagnostics: Errors or lints caused be the use of two different crate versions.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
njsmith
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Apr 28, 2023
jyn514
added
the
D-crate-version-mismatch
Diagnostics: Errors or lints caused be the use of two different crate versions.
label
Apr 28, 2023
#81659 is related and not labeled as D-crate-version-mismatch |
tgross35
added a commit
to tgross35/rust
that referenced
this issue
Aug 17, 2024
…r=fee1-dead Detect multiple crate versions on method not found When a type comes indirectly from one crate version but the imported trait comes from a separate crate version, the called method won't be found. We now show additional context: ``` error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope --> multiple-dep-versions.rs:8:10 | 8 | Type.foo(); | ^^^ method not found in `Type` | note: there are multiple different versions of crate `dependency` in the dependency graph --> multiple-dep-versions.rs:4:32 | 4 | use dependency::{do_something, Trait}; | ^^^^^ `dependency` imported here doesn't correspond to the right crate version | ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-1.rs:4:1 | 4 | pub trait Trait { | --------------- this is the trait that was imported | ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-2.rs:4:1 | 4 | pub trait Trait { | --------------- this is the trait that is needed 5 | fn foo(&self); | --- the method is available for `dep_2_reexport::Type` here ``` Fix rust-lang#128569, fix rust-lang#110926, fix rust-lang#109161, fix rust-lang#81659, fix rust-lang#51458, fix rust-lang#32611. Follow up to rust-lang#124944.
tgross35
added a commit
to tgross35/rust
that referenced
this issue
Aug 17, 2024
…r=fee1-dead Detect multiple crate versions on method not found When a type comes indirectly from one crate version but the imported trait comes from a separate crate version, the called method won't be found. We now show additional context: ``` error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope --> multiple-dep-versions.rs:8:10 | 8 | Type.foo(); | ^^^ method not found in `Type` | note: there are multiple different versions of crate `dependency` in the dependency graph --> multiple-dep-versions.rs:4:32 | 4 | use dependency::{do_something, Trait}; | ^^^^^ `dependency` imported here doesn't correspond to the right crate version | ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-1.rs:4:1 | 4 | pub trait Trait { | --------------- this is the trait that was imported | ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-2.rs:4:1 | 4 | pub trait Trait { | --------------- this is the trait that is needed 5 | fn foo(&self); | --- the method is available for `dep_2_reexport::Type` here ``` Fix rust-lang#128569, fix rust-lang#110926, fix rust-lang#109161, fix rust-lang#81659, fix rust-lang#51458, fix rust-lang#32611. Follow up to rust-lang#124944.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-crate-version-mismatch
Diagnostics: Errors or lints caused be the use of two different crate versions.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
I'm writing code that uses the py-spy and remoteprocess crates. py-spy also uses remoteprocess internally. I tried to switch to using a different version of remoteprocess with some patches, but I foolishly did this by changing my top-level crate to depend on
remoteprocess = { git = ... }
, when what I really wanted was to use a[patch.crates-io]
stanza. Anyway, the end result is that I had two differentremoteprocess
crates in my dependency tree without knowing it, and rustc gave me some spectacularly confusing errors. In particular, in a single message output, it suggested to try adding the lineuse remoteprocess::SomeTrait
, and also suggested removing the lineuse remoteprocess::SomeTrait
because it was unused.Current output
Desired output
It'd be nice if rustc detected this case and printed something hinting at what's going on?
Rationale and extra context
No response
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: