rust-lang / rust-lang/cargo

Tracking issue for --unit-graph

Open
#8,002 2 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-json-output C-tracking-issue S-needs-design S-waiting-on-feedback
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Implementation: https://github.com/rust-lang/cargo/pull/7977
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#unit-graph

Summary
The --unit-graph flag emits a JSON structure showing Cargo's internal unit graph.

Unresolved issues

  • Is there a better way to expose this information? I think in many cases, to make this useful, you have to also run cargo metadata (to get package names, for example). It seems a little silly to have to run two commands. Adding this to cargo metadata I think will be hard from a UX standpoint. It would require a superset of all flags of all commands (for example, cargo check --profile=test fundamentally changes things, so it would need to reproduce that flag). Every time I look at that, it seems really messy. There's also some flags like --target that don't interact with cargo metadata very well.
    • The primary motivator is to get access to feature relationships. But maybe there is a better way to deal with that?
  • Which parts of the output should be stabilized? This structure is very low-level, and thus inherently at high risk of changing in the future and being unstable. I think at a minimum we should document that it is not guaranteed to be backwards compatible. Should we filter some fields on stable?
  • Can't differentiate a normal check and a check for a test. The serialize implementation for CompileMode does not output the different kinds. Not sure how this should be displayed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked implementation pull request and the unstable Cargo documentation for --unit-graph. Review the three unresolved questions about exposure, stabilization, and CompileMode output. The work is complete only when the desired behavior and output policy are decided and reflected in the implementation and documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.