{"id":"e7f33eb7f0eb9eca","repo":"rust-lang/rust","slug":"local-id-should-be-u32-found-local-id","errorCode":null,"errorMessage":"local id should be u32, found {local_id:?}","messagePattern":"local id should be u32, found (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_middle/src/dep_graph/dep_node_key.rs","lineNumber":189,"sourceCode":"        let HirId { owner, local_id } = *self;\n        let def_path_hash = tcx.def_path_hash(owner.to_def_id());\n        Fingerprint::new(\n            // `owner` is local, so is completely defined by the local hash\n            def_path_hash.local_hash(),\n            local_id.as_u32() as u64,\n        )\n    }\n\n    #[inline(always)]\n    fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {\n        if tcx.key_fingerprint_style(dep_node.kind) == KeyFingerprintStyle::HirId {\n            let (local_hash, local_id) = Fingerprint::from(dep_node.key_fingerprint).split();\n            let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);\n            let def_id = tcx.def_path_hash_to_def_id(def_path_hash)?.expect_local();\n            let local_id = local_id\n                .as_u64()\n                .try_into()\n                .unwrap_or_else(|_| panic!(\"local id should be u32, found {local_id:?}\"));\n            Some(HirId { owner: OwnerId { def_id }, local_id: ItemLocalId::from_u32(local_id) })\n        } else {\n            None\n        }\n    }\n}\n\nimpl<'tcx> DepNodeKey<'tcx> for ModId {\n    #[inline(always)]\n    fn key_fingerprint_style() -> KeyFingerprintStyle {\n        KeyFingerprintStyle::DefPathHash\n    }\n\n    #[inline(always)]\n    fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {\n        self.to_def_id().to_fingerprint(tcx)\n    }\n","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/dep_graph/dep_node_key.rs#L171-L207","documentation":"In `HirId::try_recover_key` (dep_node_key.rs:189), while forcing an HirId-keyed dep node during incremental compilation, the compiler splits the stored Fingerprint and treats one half as the ItemLocalId. That half must fit in u32; if it does not, conversion fails with this panic, signalling the fingerprint is not a valid HirId encoding.","triggerScenarios":"A dep node whose fingerprint's local_id half exceeds u32::MAX is being decoded as an HirId — caused by a corrupted/invalid serialized dep graph, a fingerprint written by an incompatible compiler, or an internal hashing bug that stored a non-HirId fingerprint under a HirId-kind dep node.","commonSituations":"Corrupted incremental cache (interrupted write, disk issue, copied across machines/toolchains), toolchain mismatch leaving an incompatible previous dep graph, or an internal compiler bug in HirId fingerprinting.","solutions":["Delete the incremental cache (`rm -rf target/<profile>/incremental`) or `cargo clean` and rebuild.","Confirm the same toolchain is used for the whole build so the previous dep graph is decoder-compatible.","If it reproduces cleanly, capture a minimal repro and file a rustc issue against the HirId fingerprint/dep-node recovery path."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// DepNode keys may carry a local id that must fit in u32.\nfn local_id_as_u32(local_id: &LocalIdRef) -> Result<u32, String> {\n    match local_id {\n        LocalIdRef::U32(v) => Ok(*v),\n        other => Err(format!(\"local id should be u32, found {:?}\", other)),\n    }\n}","typeGuard":"fn local_id_is_u32(local_id: &LocalIdRef) -> bool {\n    matches!(local_id, LocalIdRef::U32(_))\n}","tryCatchPattern":null,"preventionTips":["Treat DepNode keys as opaque; do not reinterpret/stuff non-u32 values into the local-id slot.","When serializing dep-graph data, encode type tags so a widened local-id representation round-trips safely.","If you write a custom dep-node decoder, assert the variant before extracting the integer."],"tags":["rustc","dep-graph","incremental","hir"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}