rust-lang/rust · error

Query label {label} does not exist

Error message

Query label {label} does not exist

What it means

`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.

Source

Thrown at compiler/rustc_middle/src/dep_graph/dep_node.rs:386

        match tcx.key_fingerprint_style(kind) {
            KeyFingerprintStyle::Opaque | KeyFingerprintStyle::HirId => Err(()),
            KeyFingerprintStyle::Unit => Ok(DepNode::new_no_params(tcx, kind)),
            KeyFingerprintStyle::DefPathHash => {
                Ok(DepNode::from_def_path_hash(tcx, def_path_hash, kind))
            }
        }
    }

    pub fn has_label_string(label: &str) -> bool {
        dep_kind_from_label_string(label).is_ok()
    }
}

/// Maps a query label to its DepKind. Panics if a query with the given label does not exist.
pub fn dep_kind_from_label(label: &str) -> DepKind {
    dep_kind_from_label_string(label)
        .unwrap_or_else(|_| panic!("Query label {label} does not exist"))
}

// Some types are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(target_pointer_width = "64")]
mod size_asserts {
    use rustc_data_structures::static_assert_size;

    use super::*;
    // tidy-alphabetical-start
    static_assert_size!(DepKind, 2);
    static_assert_size!(DepNode, 18);
    // tidy-alphabetical-end
}

View on GitHub (pinned to 22057b88b0)

Solutions

  1. Use the exact label spelled in the current compiler's `define_dep_nodes!` table (grep the source or dump labels from a current build).
  2. Update the consuming tool/script to the rustc version that produced the dep graph.
  3. If a legitimate built-in label no longer resolves, file a rustc issue — the label table and the call site are out of sync.
Defensive patterns

Strategy: validation

Validate before calling

// Verify a label is registered before resolving it by name.
fn ensure_query_label(label: &str) -> Result<&'static QueryLabel, String> {
    QueryLabel::lookup(label)
        .ok_or_else(|| format!("query label does not exist: {}", label))
}

Type guard

fn is_known_query_label(label: &str) -> bool {
    QueryLabel::lookup(label).is_some()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03). Data as JSON: /data/errors/7255b2929b6c3aa9.json. Report an issue: GitHub.