Skip to main content

Module deps

Module deps 

Source
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§

FlagSpec
One long-flagged argument, read from the clap grammar: its --name, value kind ("boolean" / "array" / "string", the docs/explain type vocabulary), whether clap requires it, and its enum values (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 published docs/explain schema (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§

EdgeKind
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 deps built-in check over the crate graph rooted at root (one hermetic cargo metadata invocation). Returns the probe outcome, a one-line reason, and the violation report (one check: subject: evidence line each). Argument, spec, and cargo errors are ProbeOutcome::Broken — a defective probe, never a silent pass.
check_grammar
The deps check’s introspected grammar (see [grammar]).
cycles
Evaluate --acyclic: one Violation per dependency cycle — a strongly-connected component of two or more crates, or a self-loop — over allowed edges. Evidence is a concrete cycle path; the subject lists the crate names in the cycle. Output is sorted for determinism. When members_only is 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 when name resolves anywhere reachable from the workspace members over allowed edges.
forbid_path
Evaluate --forbid 'A=>B': a violation when any package named from reaches a package named to over allowed edges. Err when from is not in the graph at all (a defective assertion, not a clean pass).
layer_violations
Evaluate --layers: layers are ordered highest first — a layer may depend on layers listed after it, never before. One Violation per offending member of a lower layer that reaches a higher layer over allowed edges (so every violator is named, not just the first), each carrying its dependency path.
parse_metadata
Parse cargo metadata --format-version 1 JSON into a Graph.

Type Aliases§

Layer
A layer in a --layers stack: its label paired with the ids of the members assigned to it, in input order.