1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Cycle detection utilities for the IR target graph.
//!
//! The public entry point is [`analyse`], which accepts the target map
//! (`IrHashMap<Utf8PathBuf, BuildEdge>`) produced by IR lowering and
//! returns a [`CycleDetectionReport`]. The report carries an optional
//! detected cycle — an ordered, canonicalized list of paths — together
//! with any dependencies referenced by a target but absent from the map.
//! `order_only_deps` are intentionally excluded from traversal.
//!
//! Traversal state is owned by the private [`CycleDetector`] struct in the
//! sibling `cycle_detector` module; the iteration walks every node in the
//! target map and delegates depth-first visiting to the detector. Detected
//! cycles are normalized by [`support::canonicalize_cycle`] to produce deterministic
//! error messages regardless of traversal order. Consumed by
//! [`super::from_manifest`] after the full target map is constructed.
use Utf8PathBuf;
use ;
pub
// The test and Kani harnesses reach these through `super::*`/`super::Name`;
// expose them only in those builds so the production build neither warns nor
// carries their weight.
use canonicalize_cycle;
use canonicalize_cycle_by;
use path_eq;
use target_entry_for_path;
// Plain re-imports: the bindings stay private to `cycle` but remain reachable
// from its `#[cfg(test)]`/`#[cfg(kani)]` children through `super::*`.
use CycleDetector;
use VisitState;
use ;
use Utf8Path;
/// The result of a cycle-detection pass over the target graph.
///
/// `cycle` is `Some` when a dependency cycle was found; the vec holds the
/// cycle's nodes in canonical order, with the first node repeated as the
/// last element. `missing_dependencies` lists unresolved dependencies
/// encountered before the first detected cycle.
pub
/// Detect cycles and collect missing dependencies in `targets`.
///
/// Performs a depth-first traversal of each [`BuildEdge`]'s `inputs` and
/// `implicit_deps`. `order_only_deps` are intentionally excluded.
///
/// Returns any detected cycle path and missing dependencies encountered
/// before that cycle. Missing dependencies emit debug-level tracing events.
pub
/// Return whether `targets` contains any dependency cycle.
///
/// This drives [`CycleDetector`]'s production traversal in boolean mode.
pub