{"id":"7c5ce39cff6d8dde","repo":"rust-lang/rust","slug":"rust-forbid-dep-graph-edge-invalid","errorCode":null,"errorMessage":"RUST_FORBID_DEP_GRAPH_EDGE invalid: {}","messagePattern":"RUST_FORBID_DEP_GRAPH_EDGE invalid: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_middle/src/dep_graph/graph.rs","lineNumber":1214,"sourceCode":"    pub(super) total_duplicate_read_count: AtomicU64,\n}\n\nimpl CurrentDepGraph {\n    fn new(\n        session: &Session,\n        prev_index_space_len: usize,\n        encoder: FileEncoder<'static>,\n        previous: Arc<SerializedDepGraph>,\n    ) -> Self {\n        let mut stable_hasher = StableHasher::new();\n        previous.session_count().hash(&mut stable_hasher);\n        let anon_id_seed = stable_hasher.finish();\n\n        #[cfg(debug_assertions)]\n        let forbidden_edge = match env::var(\"RUST_FORBID_DEP_GRAPH_EDGE\") {\n            Ok(s) => match EdgeFilter::new(&s) {\n                Ok(f) => Some(f),\n                Err(err) => panic!(\"RUST_FORBID_DEP_GRAPH_EDGE invalid: {}\", err),\n            },\n            Err(_) => None,\n        };\n\n        let new_node_count_estimate = 102 * previous.live_node_count() / 100 + 200;\n\n        CurrentDepGraph {\n            encoder: GraphEncoder::new(session, encoder, prev_index_space_len, previous),\n            anon_node_to_index: ShardedHashMap::with_capacity(\n                // FIXME: The count estimate is off as anon nodes are only a portion of the nodes.\n                new_node_count_estimate / sharded::shards(),\n            ),\n            anon_id_seed,\n            #[cfg(debug_assertions)]\n            forbidden_edge,\n            #[cfg(debug_assertions)]\n            value_fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),\n            total_read_count: AtomicU64::new(0),","sourceCodeStart":1196,"sourceCodeEnd":1232,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/dep_graph/graph.rs#L1196-L1232","documentation":"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.","triggerScenarios":"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)].","commonSituations":"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.","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)."],"exampleFix":"# before\nRUST_FORBID_DEP_GRAPH_EDGE=\"typeck\" cargo build\n\n# after\nRUST_FORBID_DEP_GRAPH_EDGE=\"typeck -> layout\" cargo build","handlingStrategy":"validation","validationCode":"// Before launching the compiler/driver, sanity-check the\n// RUST_FORBID_DEP_GRAPH_EDGE environment variable.\nfn forbid_edge_is_valid() -> bool {\n    let raw = match std::env::var(\"RUST_FORBID_DEP_GRAPH_EDGE\") {\n        Ok(v) => v,\n        Err(_) => return true, // unset is always valid\n    };\n    raw.split(',')\n        .map(|s| s.trim().to_ascii_lowercase())\n        .all(|s| {\n            s.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')\n                && !s.is_empty()\n        })\n}\nassert!(forbid_edge_is_valid(),\n    \"RUST_FORBID_DEP_GRAPH_EDGE must be a comma-separated list of valid DepKind names\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rustc","incremental-compilation","debug-only","env-var","dep-graph"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}