rust-lang/rust · error
processing delegation
Error message
processing delegation
What it means
Fires in `hir_delegation_info` (hir/map.rs:872). The method expects the HIR node for `delegation_id` to be a function whose `fn_decl` carries `DelegationInfo` (the data for a `reuse`/delegation item); `.expect("processing delegation")` panics when `opt_delegation_info` returns `None`. It is an internal invariant: the query is only supposed to be called on actual delegation items (the `DelegationInfo` arena entry in hir.rs).
Solutions
- `cargo clean` and rebuild to rule out stale HIR/metadata caches.
- Try a different nightly (the delegation feature is evolving; the bug may be fixed or reverted upstream).
- Reduce the delegation usage to the minimal `reuse Path;` / `reuse fn` form to see if a specific pattern triggers it.
- Reproduces on a clean, current nightly -> file an ICE against the delegation feature with the minimal reproducer.
Defensive patterns
Strategy: validation
Validate before calling
# The delegation feature is nightly-gated; confirm the toolchain and # reduce usage to a minimal reproducer. rustc +nightly --version cargo clean && cargo +nightly build
Try / catch
cargo +nightly build || { cargo clean && cargo +nightly build; } Prevention
- Pin a specific nightly via `rust-toolchain.toml` since the delegation feature is still evolving.
- `cargo clean` after switching nightlies when using `#![feature(delegation)]`.
- Reduce delegation usage (`reuse`) to the minimal form to isolate the triggering pattern before reporting.
- Track the delegation feature's tracking issue for known-lowerering bugs.
When it happens
Trigger: The delegation-processing query (`delegation_fn_sig`, `delegation_user_specified_args`, etc. in rustc_hir_analysis/src/delegation.rs) is invoked on a `LocalDefId` whose HIR node is not a delegation function, or whose `FnDecl` did not get `DelegationInfo` attached during lowering. An internal rustc bug in the (still-gated) delegation/reuse feature.
Common situations: Using the unstable delegation feature (`#![feature(delegation)]` / `reuse`) on a nightly where lowering has a bug; a recent HIR refactor that stopped attaching `DelegationInfo`; mixing nightly versions while reusing `target/`.
Related errors
- arg must exist for infer
- must be at least one segment
- must contain self type as `SelfTy` propagation kind is…
- `Self` generic param is not found while expected
- Accessing live loans requires `-Zpolonius=next`
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/10bed4a573810103.
Report an issue: GitHub.
Appendix: source
Thrown at compiler/rustc_middle/src/hir/map.rs:872
}
pub fn hir_expect_expr(self, id: HirId) -> &'tcx Expr<'tcx> {
match self.hir_node(id) {
Node::Expr(expr) => expr,
_ => bug!("expected expr, found {}", self.hir_id_to_string(id)),
}
}
pub fn hir_opt_delegation_sig_id(self, def_id: LocalDefId) -> Option<DefId> {
self.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_sig_id()
}
pub fn hir_opt_delegation_info(self, def_id: LocalDefId) -> Option<&'tcx DelegationInfo> {
self.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_info()
}
pub fn hir_delegation_info(self, delegation_id: LocalDefId) -> &'tcx DelegationInfo {
self.hir_opt_delegation_info(delegation_id).expect("processing delegation")
}
#[inline]
fn hir_opt_ident(self, id: HirId) -> Option<Ident> {
match self.hir_node(id) {
Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
// A `Ctor` doesn't have an identifier itself, but its parent
// struct/variant does. Compare with `hir::Map::span`.
Node::Ctor(..) => match self.parent_hir_node(id) {
Node::Item(item) => Some(item.kind.ident().unwrap()),
Node::Variant(variant) => Some(variant.ident),
_ => unreachable!(),
},
node => node.ident(),
}
}
#[inline]View on GitHub (pinned to 7088e4b63a)