{"id":"10bed4a573810103","repo":"rust-lang/rust","slug":"processing-delegation","errorCode":null,"errorMessage":"processing delegation","messagePattern":"processing delegation","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_middle/src/hir/map.rs","lineNumber":873,"sourceCode":"    }\n\n    pub fn hir_expect_expr(self, id: HirId) -> &'tcx Expr<'tcx> {\n        match self.hir_node(id) {\n            Node::Expr(expr) => expr,\n            _ => bug!(\"expected expr, found {}\", self.hir_id_to_string(id)),\n        }\n    }\n\n    pub fn hir_opt_delegation_sig_id(self, def_id: LocalDefId) -> Option<DefId> {\n        self.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_sig_id()\n    }\n\n    pub fn hir_opt_delegation_info(self, def_id: LocalDefId) -> Option<&'tcx DelegationInfo> {\n        self.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_info()\n    }\n\n    pub fn hir_delegation_info(self, delegation_id: LocalDefId) -> &'tcx DelegationInfo {\n        self.hir_opt_delegation_info(delegation_id).expect(\"processing delegation\")\n    }\n\n    #[inline]\n    fn hir_opt_ident(self, id: HirId) -> Option<Ident> {\n        match self.hir_node(id) {\n            Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),\n            // A `Ctor` doesn't have an identifier itself, but its parent\n            // struct/variant does. Compare with `hir::Map::span`.\n            Node::Ctor(..) => match self.parent_hir_node(id) {\n                Node::Item(item) => Some(item.kind.ident().unwrap()),\n                Node::Variant(variant) => Some(variant.ident),\n                _ => unreachable!(),\n            },\n            node => node.ident(),\n        }\n    }\n\n    #[inline]","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/hir/map.rs#L855-L891","documentation":"expect() message in hir_delegation_info (compiler/rustc_middle/src/hir/map.rs:873). It calls opt_hir_owner_node(...).fn_decl()?.opt_delegation_info() and unwraps with 'processing delegation'. If the owner has no FnDecl or that FnDecl carries no DelegationInfo, the Option is None and this panics, meaning the def_id is not actually a delegation item.","triggerScenarios":"Calling tcx.hir_delegation_info(def_id) on a LocalDefId that is not a `reuse`/delegated fn (e.g. a regular fn, a non-fn item, or a foreign item). The DelegationInfo is only populated for items declared via the `pub reuse path::method;` delegation syntax.","commonSituations":"Compiler passes that assume every fn is a delegation when iterating; user code or macros triggering the delegation code path on a non-delegation def_id; mismatches during nightly upgrades as the `delegate` feature evolves.","solutions":["Use hir_opt_delegation_info(def_id) instead and handle the None case before processing.","If reached during normal compilation, report as an ICE; ensure the def_id actually corresponds to a delegation item.","Check the nightly version — the delegation feature is unstable and its HIR representation changes between versions."],"exampleFix":"// before\nlet info = tcx.hir_delegation_info(def_id);\n\n// after\nif let Some(info) = tcx.hir_opt_delegation_info(def_id) {\n    // process delegation\n}","handlingStrategy":"try-catch","validationCode":"// \"processing delegation\" is an internal HIR-map panic with no\n// caller-controllable precondition. No meaningful pre-call check.\n// Guard by catching the panic in tool code.","typeGuard":null,"tryCatchPattern":"// Tool authors: wrap HIR traversal that may hit this internal\n// panic in catch_unwind and degrade gracefully.\nuse std::panic::{catch_unwind, AssertUnwindSafe};\n\nlet visited = catch_unwind(AssertUnwindSafe(|| {\n    tcx.hir().walk_map(|node| process_node(tcx, node))\n}));\nmatch visited {\n    Ok(value) => { let _ = value; }\n    Err(_) => {\n        eprintln!(\"skipped delegation processing due to internal HIR-map panic\");\n        // fall back to a shallow walk that avoids the delegation path\n    }\n}","preventionTips":["Report the ICE with the HirId/DefId context so the delegation path can be fixed upstream","Pin a stable toolchain for production tooling; nightly HIR-map changes often touch delegation","Avoid triggering delegation-related macros from third-party crates in test fixtures until the bug is fixed"],"tags":["rustc","hir","delegation","ice"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}