rust-lang/rust · error
RUST_FORBID_DEP_GRAPH_EDGE invalid: {}
Error message
RUST_FORBID_DEP_GRAPH_EDGE invalid: {} What it means
Panicked while parsing the RUST_FORBID_DEP_GRAPH_EDGE environment variable in CurrentDepGraph::new (compiler/rustc_middle/src/dep_graph/graph.rs:1214). This debug-only knob (gated on debug_assertions) feeds EdgeFilter::new, which expects exactly the `source -> target` shape. The panic message echoes the Box<dyn Error> returned when the string does not contain exactly one `->` separator.
Source
Thrown at compiler/rustc_middle/src/dep_graph/graph.rs:1214
pub(super) total_duplicate_read_count: AtomicU64,
}
impl CurrentDepGraph {
fn new(
session: &Session,
prev_index_space_len: usize,
encoder: FileEncoder<'static>,
previous: Arc<SerializedDepGraph>,
) -> Self {
let mut stable_hasher = StableHasher::new();
previous.session_count().hash(&mut stable_hasher);
let anon_id_seed = stable_hasher.finish();
#[cfg(debug_assertions)]
let forbidden_edge = match env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
Ok(s) => match EdgeFilter::new(&s) {
Ok(f) => Some(f),
Err(err) => panic!("RUST_FORBID_DEP_GRAPH_EDGE invalid: {}", err),
},
Err(_) => None,
};
let new_node_count_estimate = 102 * previous.live_node_count() / 100 + 200;
CurrentDepGraph {
encoder: GraphEncoder::new(session, encoder, prev_index_space_len, previous),
anon_node_to_index: ShardedHashMap::with_capacity(
// FIXME: The count estimate is off as anon nodes are only a portion of the nodes.
new_node_count_estimate / sharded::shards(),
),
anon_id_seed,
#[cfg(debug_assertions)]
forbidden_edge,
#[cfg(debug_assertions)]
value_fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),
total_read_count: AtomicU64::new(0),View on GitHub (pinned to 22057b88b0)
Solutions
- Unset or fix RUST_FORBID_DEP_GRAPH_EDGE so it matches `source -> target`, where each side is a `&`-separated list of substrings (e.g. `typeck -> lint`).
- If you did not mean to set it, remove it from the environment / .cargo/config.toml / test harness before rebuilding.
- Use a release/non-debug rustc build to bypass the check entirely (not recommended for compiler debugging).
Example fix
# before RUST_FORBID_DEP_GRAPH_EDGE="typeck" cargo build # after RUST_FORBID_DEP_GRAPH_EDGE="typeck -> layout" cargo build
Defensive patterns
Strategy: validation
Validate before calling
// Before launching the compiler/driver, sanity-check the
// RUST_FORBID_DEP_GRAPH_EDGE environment variable.
fn forbid_edge_is_valid() -> bool {
let raw = match std::env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
Ok(v) => v,
Err(_) => return true, // unset is always valid
};
raw.split(',')
.map(|s| s.trim().to_ascii_lowercase())
.all(|s| {
s.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')
&& !s.is_empty()
})
}
assert!(forbid_edge_is_valid(),
"RUST_FORBID_DEP_GRAPH_EDGE must be a comma-separated list of valid DepKind names"); Prevention
- Only set RUST_FORBID_DEP_GRAPH_EDGE on nightly toolchains that recognize the DepKind names you list
- Cross-check every edge name against the DepKind variant list for the exact rustc commit you build against
- Remove the variable in production/CI builds unless you are intentionally testing dep-graph constraints
- When upgrading the toolchain, re-validate the names against the new DepKind enum
When it happens
Trigger: Launching rustc (or a debug/dev build of it) with RUST_FORBID_DEP_GRAPH_EDGE set to a value with zero or more than one `->`, e.g. `foo`, `a -> b -> c`, or an empty string after trimming. Only fires under debug_assertions because the whole forbidden_edge block is #[cfg(debug_assertions)].
Common situations: Compiler hackers running incremental-compilation red-green regression tests with a mistyped filter; CI that copies an env var template and forgets the `->`; switching rustc versions where the filter syntax changed.
Related errors
- forbidden edge {:?} -> {:?} created
- Error: trying to record dependency on DepNode {dep_node} in
- counting sort fills every slot of a kind's range
- Error: A dep graph node ({kind:?}) does not have an unique i
- dep node {prev_index:?} is unexpectedly red
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/7c5ce39cff6d8dde.json.
Report an issue: GitHub.