rust-lang/rust · critical
argument names not encoded for a function
Error message
argument names not encoded for a function
What it means
Fires in `get_fn_has_self_parameter` (decoder.rs:1380). The function looks up the `fn_arg_idents` table for a `DefIndex` and `.expect()`s an entry, because a function is assumed to have its argument names encoded. A missing entry means a non-function `DefIndex` was queried through this path, or the function's argument names were never serialized.
Source
Thrown at compiler/rustc_metadata/src/rmeta/decoder.rs:1380
let children = self.root.tables.ambig_module_children.get(self, id);
if !children.is_default() {
for child in children.decode((self, tcx)) {
yield child;
}
}
}
}
fn is_item_mir_available(&self, id: DefIndex) -> bool {
self.root.tables.optimized_mir.get(self, id).is_some()
}
fn get_fn_has_self_parameter(&self, tcx: TyCtxt<'_>, id: DefIndex) -> bool {
self.root
.tables
.fn_arg_idents
.get(self, id)
.expect("argument names not encoded for a function")
.decode((self, tcx))
.nth(0)
.is_some_and(|ident| matches!(ident, Some(Ident { name: kw::SelfLower, .. })))
}
fn get_associated_item_or_field_def_ids(
&self,
tcx: TyCtxt<'_>,
id: DefIndex,
) -> impl Iterator<Item = DefId> {
self.root
.tables
.associated_item_or_field_def_ids
.get(self, id)
.unwrap_or_else(|| self.missing("associated_item_or_field_def_ids", id))
.decode((self, tcx))
.map(move |child_index| self.local_def_id(child_index))
}View on GitHub (pinned to 7088e4b63a)
Solutions
- `cargo clean` and rebuild to regenerate `fn_arg_idents` for the current schema.
- Ensure the crate providing the function and the crate querying it share one toolchain version.
- If the function is from a prebuilt dependency, rebuild it with the active compiler instead of reusing the old rlib.
- Reproduces on a clean single-toolchain build -> file an ICE; the query was likely routed to a non-function `DefIndex`.
Defensive patterns
Strategy: retry
Validate before calling
# Regenerate function-arg metadata for the current schema cargo clean cargo build
Try / catch
cargo build || { cargo clean && cargo build; } Prevention
- Rebuild dependencies with the active compiler; do not reuse rlibs from another rustc.
- `cargo clean` after toolchain updates.
- Pin toolchain versions across the build graph.
When it happens
Trigger: Querying `fn_has_self_parameter` on a `DefIndex` that is not a function (e.g. a const, static, or type alias routed here by a stale query cache); reading a function whose metadata was written without `fn_arg_idents` (older encoder, or an extern/imported fn without encoded args).
Common situations: Cross-version artifact reuse where the encoder stopped/started writing `fn_arg_idents`; incremental cache referencing a renumbered `DefIndex`; querying self-ness of a function from a proc-macro or older rlib.
Related errors
- no encoded ident for item
- variants are not encoded for an enum
- provided `DefIndex` must refer to a module-like item
- no parent for a constructor
- no encoded attributes for a structure or variant
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/ca0973f23cc1c3b7.
Report an issue: GitHub.