Fix parse_cargo_tree_output misclassifying dev-dependencies as host deps (#3976)
Fix `parse_cargo_tree_output` incorrectly classifying
`[dev-dependencies]` as host dependencies when they follow
`[build-dependencies]` for the same crate.
This causes platform-conditional features to leak across platforms in
the generated BUILD files. For instance, the `tokio` feature `taskdump`
that can only be enabled on linux could leak to other platforms.
Example dependency tree that triggers the issue:
```
;my-crate v0.1.0 (/my-crate);;
`-- ;tokio v1.49.0;bytes,full,taskdump;
[build-dependencies]
`-- ;anyhow v1.0.100;default,std;
[dev-dependencies]
`-- ;tokio-test v0.4.4;;
`-- ;tokio v1.49.0;bytes,full,taskdump; (*)
```
This PR also updates surrounding code in `parse_cargo_tree_output`. Let
me know if you'd prefer a minimal fix instead.This repository provides rules for building Rust projects with Bazel.
The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.
Please refer to the full documentation.