[Feature Request] Overwrite The Version of a Dependency's Dependency #13625
Labels
A-dependency-resolution
Area: dependency resolution and the resolver
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-info
Status: Needs more info, such as a reproduction or more background for a feature request.
Problem
This feature proposal is intended to allow setting the version of a dependency of a dependency.
Consider the following dependency graph:
Currently, Cargo compiles two copies of the DepB crate, but in many real-world scenarios, we don't need to emphasize that the two use different versions. Thus, allowing overwriting of the version of a secondary dependency could theoretically be an effective way to save on compilation footprint; at the same time, since this behavior is done proactively, there are theoretically no unexpected serious bugs - after all, you can always drop this feature.
For an example in practice, imagine a library that provides some predefined data structures. Typically, these libraries implement the optional
serde::Ser/Deserialize
for their own data structures, which means that these libraries all need to include aserde
. While differences in patches are handled by cargo, some minors or even majors that don't affect the implementation are not optimized.Proposed Solution
Continue to follow the dependency diagram above. The syntax I envision is:
This should be expressed as the following dependency:
Notes
All actual syntax and keywords are for demonstration purposes only. The FEATURE REQUEST simply raises the need for this feature. If this request is accepted, the proposer can participate in the implementation.
The text was updated successfully, but these errors were encountered: