Expand description
The deps built-in check’s crate-graph queries.
The resolved dependency graph comes from cargo metadata --format-version 1 --locked --offline (hermetic by construction); this module parses that
JSON into a Graph and answers the crate-level invariant questions:
is crate X anywhere in the tree (deny_paths), does workspace member
A reach crate B (forbid_path), do any crates resolve at more than one
version (Graph::duplicates), is the graph free of cycles (cycles),
and does it respect a declared layer order (layer_violations, with
membership from assign_layers). Every violation carries its evidence —
a dependency path, a concrete cycle, or the duplicated version list — so a
red answer is never just a name.
Structs§
- Flag
Spec - One long-flagged argument, read from the clap grammar: its
--name, valuekind("boolean"/"array"/"string", thedocs/explaintypevocabulary), whether clap requires it, and its enumvalues(empty when the value is free-form). - Grammar
- The introspected grammar of a tool or built-in check: every long flag’s
spec, plus the names of all clap-required arguments — flags and positionals
(named by their field id, e.g.
path/probe). The single source of truth behind the publisheddocs/explainschema (a test reconciles the two) and the valid-flags hint on a bad argument. - Graph
- The resolved crate graph.
- Package
- One resolved package.
- Violation
- Evidence for one violated assertion.
Enums§
- Edge
Kind - A dependency edge kind, as cargo models it.
Functions§
- assign_
layers - Assign each workspace member to a layer by the
matches(index, name)predicate. Returns the layers (label + member ids, input order preserved) and the names of members matching no layer. Errors when a member matches more than one layer — an ambiguous spec, not a clean pass. - check
- Run a
depsbuilt-in check over the crate graph rooted atroot(one hermeticcargo metadatainvocation). Returns the probe outcome, a one-line reason, and the violation report (onecheck: subject: evidenceline each). Argument, spec, and cargo errors areProbeOutcome::Broken— a defective probe, never a silent pass. - check_
grammar - The
depscheck’s introspected grammar (see [grammar]). - cycles
- Evaluate
--acyclic: oneViolationper dependency cycle — a strongly-connected component of two or more crates, or a self-loop — overallowededges. Evidence is a concrete cycle path; the subject lists the crate names in the cycle. Output is sorted for determinism. Whenmembers_onlyis set, only cycles among workspace members are reported (the actionable form: crate cycles among third-party deps are almost always dev-dependency noise you cannot fix). - deny_
paths - Evaluate
--deny NAME: a violation whennameresolves anywhere reachable from the workspace members overallowededges. - forbid_
path - Evaluate
--forbid 'A=>B': a violation when any package namedfromreaches a package namedtooverallowededges.Errwhenfromis not in the graph at all (a defective assertion, not a clean pass). - layer_
violations - Evaluate
--layers:layersare ordered highest first — a layer may depend on layers listed after it, never before. OneViolationper offending member of a lower layer that reaches a higher layer overallowededges (so every violator is named, not just the first), each carrying its dependency path. - parse_
metadata - Parse
cargo metadata --format-version 1JSON into aGraph.
Type Aliases§
- Layer
- A layer in a
--layersstack: its label paired with the ids of the members assigned to it, in input order.