feat(tree): show artifact dependency details#17075
Conversation
|
r? @ehuss rustbot has assigned @ehuss. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Copy, Hash, Eq, Clone, PartialEq)] |
There was a problem hiding this comment.
tip: splitting changes like this into their own commit make it easier / faster for maintainers to review, see https://epage.github.io/dev/pr-style/#c-atomic
| .with_status(0) | ||
| .run(); | ||
|
|
||
| p.cargo("tree -Z bindeps -e features") |
There was a problem hiding this comment.
We ask for new test cases to be added in their own commit first, with tests passing in that commit, see https://epage.github.io/dev/pr-style/#c-test
| ws: &Workspace<'_>, | ||
| graph: &'a Graph<'_>, | ||
| node_index: NodeId, | ||
| incoming_edge: Option<&Edge>, |
There was a problem hiding this comment.
If we are relying on the incoming edge. Are there times where we have different edges but the same node? For example, what happens if a package has a regular dep and an artifact dep on a package?
#16192 also deals with edges and may have other relevant concerns.
| r#"... | ||
| foo v0.1.0 ([ROOT]/foo) | ||
| └── bar v0.1.0 ([ROOT]/foo/bar) | ||
| └── bar v0.1.0 ([ROOT]/foo/bar) (artifact: bin, target=[ALT_TARGET]) |
There was a problem hiding this comment.
This PR is marked as closing the issue but part of the issue is how to visually represent the graph.
2eb63a0 to
83d0988
Compare
|
I traced the design history through #10593, #14804, #14658, RFC 3028, The concrete proposal in #10593 / #14804 was to annotate artifact This PR takes that minimal textual approach, but spells the annotation I did not implement dashed-line rendering in this PR. Line style could If dashed-line rendering would be valuable, I am happy to implement that I also changed this from |
83d0988 to
78717bd
Compare
This comment has been minimized.
This comment has been minimized.
|
Updated this PR around the design discussion and the PR-structure feedback. Changes in this revision:
I left the review threads open for reviewer confirmation. Verified locally: |
Add cargo tree coverage for artifact dependency display before changing the visual output. The baseline records the current behavior: artifact dependencies are displayed in their dependency section without artifact-specific annotation. The cases cover selected binaries, multiple artifact kinds, explicit artifact targets, feature-edge output, normal and artifact edges to the same package, build-dependency placement, and lib=true.
Carry artifact dependency metadata on cargo tree edges and annotate artifact edges with a compact suffix like (bin), (bin:name), or (bin, target). The annotation is edge-local because the same package can be reached through both normal and artifact dependency edges, or through multiple artifact aliases with different requested artifacts or targets. Artifact dependencies remain in their normal/build/dev dependency sections. Render lib=true as two relationships: a normal dependency edge plus an artifact dependency edge. This matches the manifest semantics without needing a separate lib=true suffix. Refs rust-lang#14804.
78717bd to
4280c6a
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
We have other attempts at annotating edges which gets weird in some cases. I wonder if we should instead treat these like features: an artifact is a node that depends on the package / lib. |
|
Not dug into all the details of this implementation (particularly when there are bigger questions) but
|
|
☔ The latest upstream changes (possibly #17169) made this pull request unmergeable. Please resolve the merge conflicts. |
What does this PR try to resolve?
cargo tree -Z bindepscurrently shows artifact dependencies as ordinary dependency edges, without showing which artifact was requested. This makes several artifact-dependency shapes indistinguishable in tree output, including selected binaries, multiple artifact kinds, explicit artifact targets, and dependencies that are both normal Rust dependencies and artifact dependencies.This PR carries artifact dependency metadata on
cargo treeedges and annotates artifact edges with a compact suffix:For
lib = true, the tree renders the two relationships separately: a normal dependency edge plus an artifact dependency edge. This matches the manifest semantics and avoids a separatelib=truesuffix.Refs #14804.
Design notes
The annotation is edge-local, not package-global. The same package can be reached through a normal dependency edge, an artifact dependency edge, or multiple artifact aliases with different requested artifacts or targets. Keeping metadata on the edge lets those cases render differently without changing dependency resolution or package node identity.
Artifact dependencies stay in their existing normal/build/dev dependency sections. This follows the prior discussion that artifact dependencies are still dependency edges of those kinds; the suffix only describes the artifact request on that edge.
This PR does not implement a dashed or otherwise distinct line style for artifact edges. A line style could still be added later, but it would not replace the textual suffix because the suffix carries artifact kind, selected binary, and target details.
Commit structure
The first commit adds tests that pass with the existing output, recording the current unannotated behavior. The second commit updates the expected output while adding the edge metadata and rendering changes.
How should we test and review this PR?
Review the test output changes in the second commit; they are intended to show the display contract directly.
Local verification: