Fix logic for marking crate as "multi" #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Description of Changes
Fixed the logic that marks crates as "multi" (i.e. crates that are included multiple times under different names). Previously the code used "chunks" to iterate over a node's dependencies, which would yield non-overlapping pairs of dependencies. The issue arises in the following situation:
ab|b'c|de|
Here the dependency
b
is included twice but the chunking means that a&b are compared, and so are b'&c, but never b&b'.The new code uses a sliding window checking pairs like:
ab|bb'|b'c|cd|de
Due to Rust's mutability rules we have to use indexes rather than a nice iterator since no
&mut windows()
method exists (as it would be unsound).Related Issues
#69 (in particular see: #69 (comment))
Testing
I've cloned
cargo-deny
locally and set the krates dependency to my local version and then ran it on my project (usingcargo run -- --manifest-path ~/my/to/my/rust/project/Cargo.toml check advisories
) and it worked. I then set the krates dependency back to 0.16 and then re-ran the command and it failed with:So I'm confident my change has fixed the issue I was facing.