Correctly identify and distinguish crates in the dependency tree #21751
Unanswered
nicola-gigante
asked this question in
Q&A
Replies: 1 comment 3 replies
-
|
Crates don't have names. They sometimes have display names, which are not required to be unique and are not used for anything other than presentation. Dependencies have names. When you rename the crate in Cargo.toml, you rename the dependency. A The difference between canonical name and crate name is that crate_name has dashes replaced with underscores. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I would need to distinguish crates in the dependency tree with the maximum fidelity.
I have a few questions when using
display_name()andorigin()for my purposes.To start, one thing I've noticed is that if I have a renamed dependency in
Cargo.tomlsuch as:What I get from
hir::Crate::display_name()is still"my-crate"instead of"renamed-crate". However the latter is usefulbecause it's how the crate can be named in the source code. How do I get to this name?
Another issue is that Cargo allows different crates from different registries to have the same name and even the same version.
In this case it seems to me that both
display_name()andversion()would be equal, and there is nothing inhir::Crateabout the source registry. Is there a permanent way to distinguish two crates with the same name and version coming from different registries? By permanent I mean that is reproducible across different calls of the tool and of RA, so not the actual salsa id of thehir::Crate.In all my tests I get that the
crate_name()andcanonical_name()of the crate'sdisplay_name()are the same. What's the difference between the two?Thanks, any help is appreciated :)
Beta Was this translation helpful? Give feedback.
All reactions