{"record":{"id":"3cdbfab54e656288","repo":"rust-lang/rust","slug":"no-parent-for-a-constructor","errorCode":null,"errorMessage":"no parent for a constructor","messagePattern":"no parent for a constructor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_metadata/src/rmeta/decoder.rs","lineNumber":1453,"sourceCode":"\n    fn get_item_attrs(\n        &self,\n        tcx: TyCtxt<'_>,\n        id: DefIndex,\n    ) -> impl Iterator<Item = hir::Attribute> {\n        self.root\n            .tables\n            .attributes\n            .get(self, id)\n            .unwrap_or_else(|| {\n                let def_key = self.def_key(id);\n                match def_key.disambiguated_data.data {\n                    DefPathData::Ctor => {\n                        // Structure and variant constructors don't have any attributes encoded for them,\n                        // but we assume that someone passing a constructor ID actually wants to look at\n                        // the attributes on the corresponding struct or variant.\n                        assert_eq!(def_key.disambiguated_data.data, DefPathData::Ctor);\n                        let parent_id = def_key.parent.expect(\"no parent for a constructor\");\n                        self.root\n                            .tables\n                            .attributes\n                            .get(self, parent_id)\n                            .expect(\"no encoded attributes for a structure or variant\")\n                    }\n                    DefPathData::SyntheticCoroutineBody => {\n                        // SyntheticCoroutineBodies cannot have attributes\n                        LazyArray::default()\n                    }\n                    _ => panic!(\"Definition key {def_key:?} of type `{:?}` did not have any attributes stored\", def_key.disambiguated_data.data)\n                }\n            })\n            .decode((self, tcx))\n    }\n\n    fn get_inherent_implementations_for_type<'tcx>(\n        &self,","sourceCodeStart":1435,"sourceCodeEnd":1471,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_metadata/src/rmeta/decoder.rs#L1435-L1471","documentation":"Fires inside `get_item_attrs` (decoder.rs:1453). When a constructor's attributes are requested, the decoder reads the constructor's `def_key` and expects it to carry a `parent` pointing at the owning struct/variant; `def_key.parent.expect(\"no parent for a constructor\")` panics when that parent is `None`. A constructor (tuple-struct/enum-variant ctor) without a parent is structurally invalid metadata.","triggerScenarios":"Looking up attributes on a constructor `DefIndex` whose `def_key` was serialized without a parent field (encoder bug or truncated metadata); reading a constructor from a partially-written/corrupted rmeta blob.","commonSituations":"Interrupted build leaving a half-written `.rlib`; rmeta produced by a buggy nightly; cross-version metadata reuse.","solutions":["`cargo clean` to discard the truncated/corrupt artifact and rebuild.","Re-run the build (an interrupted previous build may have left a partial rmeta).","Verify disk is not full and the build was not killed mid-link.","If it reproduces on a clean build, file an ICE: a constructor was encoded without its parent def_key."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# A constructor without a parent implies a truncated rmeta; rebuild clean\n# and check the build was not interrupted / disk not full.\ndf -h .                # ensure disk has space\ncargo clean && cargo build","typeGuard":null,"tryCatchPattern":"cargo build || { df -h . && cargo clean && cargo build; }","preventionTips":["Do not reuse a `target/` left by an interrupted/killed build.","Ensure the build volume has free disk space before large builds.","Run `cargo clean` after toolchain changes."],"tags":["metadata","rmeta","decoder","constructors","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}