{"record":{"id":"b9905cd7754cb0db","repo":"rust-lang/rust","slug":"no-encoded-ident-for-item","errorCode":null,"errorMessage":"no encoded ident for item","messagePattern":"no encoded ident for item","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_metadata/src/rmeta/decoder.rs","lineNumber":1058,"sourceCode":"\n    fn item_name(&self, item_index: DefIndex) -> Symbol {\n        self.opt_item_name(item_index).expect(\"no encoded ident for item\")\n    }\n\n    fn opt_item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Option<Ident> {\n        let name = self.opt_item_name(item_index)?;\n        let span = self\n            .root\n            .tables\n            .def_ident_span\n            .get(self, item_index)\n            .unwrap_or_else(|| self.missing(\"def_ident_span\", item_index))\n            .decode((self, tcx));\n        Some(Ident::new(name, span))\n    }\n\n    fn item_ident(&self, tcx: TyCtxt<'_>, item_index: DefIndex) -> Ident {\n        self.opt_item_ident(tcx, item_index).expect(\"no encoded ident for item\")\n    }\n\n    #[inline]\n    pub(super) fn map_encoded_cnum_to_current(&self, cnum: CrateNum) -> CrateNum {\n        if cnum == LOCAL_CRATE { self.cnum } else { self.cnum_map[cnum] }\n    }\n\n    fn def_kind(&self, item_id: DefIndex) -> DefKind {\n        self.root\n            .tables\n            .def_kind\n            .get(self, item_id)\n            .unwrap_or_else(|| self.missing(\"def_kind\", item_id))\n    }\n\n    fn get_span(&self, tcx: TyCtxt<'_>, index: DefIndex) -> Span {\n        self.root\n            .tables","sourceCodeStart":1040,"sourceCodeEnd":1076,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_metadata/src/rmeta/decoder.rs#L1040-L1076","documentation":"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.","triggerScenarios":"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.","commonSituations":"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`.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Run before building to ensure a consistent metadata baseline\nrustc --version --verbose   # confirm toolchain\nfind target -name '*.rmeta' -newer Cargo.lock -delete 2>/dev/null || true\ncargo clean  # nuclear option: guarantees fresh metadata","typeGuard":null,"tryCatchPattern":"# When driving rustc as a subprocess, treat its non-zero/ICE exit as retryable:\nif cargo build; then\n  echo ok\nelse\n  rc=$?\n  if cargo build 2>&1 | grep -q 'no encoded ident for item'; then\n    cargo clean && cargo build   # one retry after cleaning metadata\n  fi\n  exit $rc\nfi","preventionTips":["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."],"tags":["metadata","rmeta","decoder","ice","incremental-compilation"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}