{"id":"7255b2929b6c3aa9","repo":"rust-lang/rust","slug":"query-label-label-does-not-exist","errorCode":null,"errorMessage":"Query label {label} does not exist","messagePattern":"Query label (.+?) does not exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_middle/src/dep_graph/dep_node.rs","lineNumber":386,"sourceCode":"\n        match tcx.key_fingerprint_style(kind) {\n            KeyFingerprintStyle::Opaque | KeyFingerprintStyle::HirId => Err(()),\n            KeyFingerprintStyle::Unit => Ok(DepNode::new_no_params(tcx, kind)),\n            KeyFingerprintStyle::DefPathHash => {\n                Ok(DepNode::from_def_path_hash(tcx, def_path_hash, kind))\n            }\n        }\n    }\n\n    pub fn has_label_string(label: &str) -> bool {\n        dep_kind_from_label_string(label).is_ok()\n    }\n}\n\n/// Maps a query label to its DepKind. Panics if a query with the given label does not exist.\npub fn dep_kind_from_label(label: &str) -> DepKind {\n    dep_kind_from_label_string(label)\n        .unwrap_or_else(|_| panic!(\"Query label {label} does not exist\"))\n}\n\n// Some types are used a lot. Make sure they don't unintentionally get bigger.\n#[cfg(target_pointer_width = \"64\")]\nmod size_asserts {\n    use rustc_data_structures::static_assert_size;\n\n    use super::*;\n    // tidy-alphabetical-start\n    static_assert_size!(DepKind, 2);\n    static_assert_size!(DepNode, 18);\n    // tidy-alphabetical-end\n}\n","sourceCodeStart":368,"sourceCodeEnd":400,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/dep_graph/dep_node.rs#L368-L400","documentation":"`dep_kind_from_label` (dep_node.rs:386) maps a human-readable query label string to its DepKind by looking it up in the table generated by `define_dep_nodes!`. If the label matches no entry it panics, because callers (dep-graph inspection, profiling) assume every label resolves. This guards the label→kind mapping used by `-Zquery-dep-graph` and related introspection.","triggerScenarios":"Calling `dep_kind_from_label`/`has_label_string` with a label absent from the generated dep-node table — a typo, a query renamed/removed across rustc versions, or tooling that hardcodes a label from a different compiler.","commonSituations":"External tooling or scripts that consume `-Zquery-dep-graph` output and pass labels back in; running a profiling/inspection helper built against one rustc version against metadata from another; typos in hand-written label strings during rustc development.","solutions":["Use the exact label spelled in the current compiler's `define_dep_nodes!` table (grep the source or dump labels from a current build).","Update the consuming tool/script to the rustc version that produced the dep graph.","If a legitimate built-in label no longer resolves, file a rustc issue — the label table and the call site are out of sync."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify a label is registered before resolving it by name.\nfn ensure_query_label(label: &str) -> Result<&'static QueryLabel, String> {\n    QueryLabel::lookup(label)\n        .ok_or_else(|| format!(\"query label does not exist: {}\", label))\n}","typeGuard":"fn is_known_query_label(label: &str) -> bool {\n    QueryLabel::lookup(label).is_some()\n}","tryCatchPattern":null,"preventionTips":["Query labels are static, compiler-registered strings; only use labels exported by the current rustc API surface.","If you maintain a plugin/procedural layer that names queries, register labels at startup and unit-test for their presence.","Do not copy label strings from older rustc versions into newer code without verifying they still exist."],"tags":["rustc","dep-graph","query","debugging"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}