rust-lang/rust · critical
no encoded ident for item
Error message
no encoded ident for item
What it means
Fires in the rmeta decoder when `item_ident()` (decoder.rs:1058) calls `opt_item_name` and the item name table has no entry for the given `DefIndex`. The decoder assumes every definition it is asked to name has an encoded identifier; a missing entry means the serialized metadata is internally inconsistent with the query that requested the ident. This is an internal-compiler-error class panic, almost always a symptom of artifact corruption or a rustc bug rather than user-code error.
Source
Thrown at compiler/rustc_metadata/src/rmeta/decoder.rs:1058
fn item_name(&self, item_index: DefIndex) -> Symbol {
self.opt_item_name(item_index).expect("no encoded ident for item")
}
fn opt_item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Option<Ident> {
let name = self.opt_item_name(item_index)?;
let span = self
.root
.tables
.def_ident_span
.get(self, item_index)
.unwrap_or_else(|| self.missing("def_ident_span", item_index))
.decode((self, tcx));
Some(Ident::new(name, span))
}
fn item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Ident {
self.opt_item_ident(tcx, item_index).expect("no encoded ident for item")
}
#[inline]
pub(super) fn map_encoded_cnum_to_current(&self, cnum: CrateNum) -> CrateNum {
if cnum == LOCAL_CRATE { self.cnum } else { self.cnum_map[cnum] }
}
fn def_kind(&self, item_id: DefIndex) -> DefKind {
self.root
.tables
.def_kind
.get(self, item_id)
.unwrap_or_else(|| self.missing("def_kind", item_id))
}
fn get_span(&self, tcx: TyCtxt<'_>, index: DefIndex) -> Span {
self.root
.tablesView on GitHub (pinned to 7088e4b63a)
Solutions
- Run `cargo clean` then rebuild from scratch to eliminate stale/inconsistent metadata.
- Verify every crate in the graph is built with the same `rustc --version` (run `rustup show` and check `Cargo.lock` toolchain pinning); reinstall the toolchain if it is partial.
- Delete the offending dependency's artifact cache (`rm -rf target/debug/deps/<crate>*`) so it is re-fetched/recompiled.
- If the panic reproduces on a clean build with a single toolchain, minimize it (`cargo bugreport` / `rustc -Z tiny-annotation` / `cargo-minimize`) and file an ICE against rustc with the backtrace.
Defensive patterns
Strategy: retry
Validate before calling
# Run before building to ensure a consistent metadata baseline rustc --version --verbose # confirm toolchain find target -name '*.rmeta' -newer Cargo.lock -delete 2>/dev/null || true cargo clean # nuclear option: guarantees fresh metadata
Try / catch
# When driving rustc as a subprocess, treat its non-zero/ICE exit as retryable:
if cargo build; then
echo ok
else
rc=$?
if cargo build 2>&1 | grep -q 'no encoded ident for item'; then
cargo clean && cargo build # one retry after cleaning metadata
fi
exit $rc
fi Prevention
- Never reuse a `target/` directory across different rustc versions; `cargo clean` after every toolchain change.
- Pin the toolchain (`rust-toolchain.toml`) in CI and locally so the whole graph shares one compiler.
- Avoid interrupting builds mid-link; a half-written rlib triggers decoder panics later.
- In CI, start from a clean `target/` when the toolchain image changes.
When it happens
Trigger: Decoding a `DefIndex` whose name was never encoded (e.g. an anonymous/synthetic definition queried through a path that expects a named item), or reading an `.rlib`/rmeta produced by a different rustc version whose encoding schema changed. Also seen when incremental-compilation caches reference a definition that was pruned or renumbered after a stale `target/` directory is reused.
Common situations: Switching toolchains (stable <-> nightly, or a rustup update) without `cargo clean`; reusing a `target/` dir across commits that changed the dependency graph; a dependency recompiled with a patched rustc whose rmeta layout differs; corrupted download of an `.rlib`.
Related errors
- variants are not encoded for an enum
- provided `DefIndex` must refer to a module-like item
- argument names not encoded for a function
- 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/b9905cd7754cb0db.
Report an issue: GitHub.