Open csmulhern opened 2 years ago
In actuality, it is only ignoring renames that only change dashes into underscores.
The offending code is here:
From what I can tell, the NodeDep name from cargo_metadata should already be the correct name, with renames taken into account (see: https://docs.rs/cargo_metadata/latest/cargo_metadata/struct.NodeDep.html). @UebelAndre, what is the purpose of get_target_alias
here?
The problem is that the dependency name is automatically renamed (or 'sanitized' in above lingo) for modules containing hyphens. This means get_target_alias cannot actually tell the difference between an automatic rename, and an intentional rename.
I.e. both:
[dependencies.async_trait]
package = "async-trait"
version = "0.1.51"
And
[dependencies]
async-trait = "0.1.51"
will have a dependency name of async_trait
, even though the former is explicitly aliased, whereas the latter is not. This will cause get_target_alias
to return None in both cases, meaning the alias will ignore the rename and use async-trait
in both cases.
@UebelAndre, any thoughts on how we can make it so at least the first case will use a proper alias?
It seems like one angle would be to use Node.dependencies
instead of Node.deps
, which doesn't expose automatic renaming. Not sure how to efficiently go from a PackageId to the dependency metadata however.
For example, this entry in Cargo.toml:
Will generate an alias such as:
Whereas I'd expect the name to be
async_trait
(vsasync-trait
).