Resolver deps returns duplicates #7985
Labels
A-cargo-api
Area: cargo-the-library API and internal code issues
A-dependency-resolution
Area: dependency resolution and the resolver
C-bug
Category: bug
Problem
The
Resolver::deps
method returns duplicate deps in situations where a dependency is depended upon with different features in different places. For example, here is what thecargo metadata
command does to deduplicate these. Normal build graphs (here) just chew on the duplicates, but is otherwise unaffected.Would it be possible for these to be de-duplicated in the Resolver? Otherwise, any code calling that method will need to deal with the duplicates.
Steps
I wrote a test in the resolver-tests crate to demonstrate what I mean. I'm not sure if there is a better way to write these kinds of tests. The dep graph looks like this:
Running
cargo test -- --nocapture
you can see that this will print:Notice that the
bitflags
dependency appears 3 times. I would expect it to appear once.Possible Solution(s)
I'm not sure how these duplicates appear, but it would be nice if the duplicate edges weren't added to the graph. If that is not possible, maybe a separate pass to de-duplicate the results? I'm not sure where to begin looking for why this happens. I'm guessing somewhere feature unification happens, and the dependencies are merged without de-duplicating the edges?
cc @Eh2406
The text was updated successfully, but these errors were encountered: