{"record":{"id":"769f29b2798dac8a","repo":"tracel-ai/burn","slug":"deserialize-unit-struct-is-not-implemented","errorCode":null,"errorMessage":"deserialize_unit_struct is not implemented","messagePattern":"deserialize_unit_struct is not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-store/src/nested/de.rs","lineNumber":312,"sourceCode":"        }\n    }\n\n    fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\"deserialize_unit is not implemented\")\n    }\n\n    fn deserialize_unit_struct<V>(\n        self,\n        _name: &'static str,\n        _visitor: V,\n    ) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\"deserialize_unit_struct is not implemented\")\n    }\n\n    fn deserialize_newtype_struct<V>(\n        self,\n        _name: &'static str,\n        visitor: V,\n    ) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        let value = self\n            .value\n            .ok_or_else(|| custom_err(\"expected value for newtype struct but got None\"))?;\n        visitor.visit_newtype_struct(Deserializer::<A>::new(\n            value,\n            self.default_for_missing_fields,\n        ))\n    }","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-store/src/nested/de.rs#L294-L330","documentation":"The nested-value deserializer panics on `deserialize_unit_struct` because unit-like structs (e.g., `struct Marker;`) have no NestedValue representation. Any record type referencing such a struct hits this deliberate unimplemented!() during deserialization.","triggerScenarios":"Deserializing a Burn record that includes a field whose type is a unit struct (a braced-less struct with no fields), causing serde to call Deserializer::deserialize_unit_struct.","commonSituations":"Marker types used in module/record definitions (e.g., type-state markers); schema refactors that introduced marker fields; version drift between the code that saved the checkpoint and the code loading it.","solutions":["Replace the unit-struct field with an empty struct that implements Deserialize via a zero-field struct (deserialize_struct with empty fields) or remove it entirely.","Use PhantomData instead of a unit struct for type markers.","Regenerate the checkpoint to match the supported record schema.","Add #[serde(skip)] semantics by restructuring the type so the marker is not part of the serialized data."],"exampleFix":"// before\nstruct Marker;\nstruct Item { m: Marker } // -> deserialize_unit_struct panic\n// after\nstruct Item { _m: core::marker::PhantomData<Marker> } // not serialized","handlingStrategy":"validation","validationCode":"// Replace unit structs with PhantomData markers:\n// struct Marker;\n// struct Item { _m: PhantomData<Marker> }  // not part of serialized data","typeGuard":null,"tryCatchPattern":"let record = std::panic::catch_unwind(|| from_nested_value::<MyItem>(value.clone()))\n    .map_err(|_| \"record contains unit struct: not supported by nested deserializer\");","preventionTips":["Avoid unit structs as fields in serializable record types.","Use PhantomData for type-state markers.","Round-trip test records after introducing new marker types."],"tags":["rust","serde","deserialization","burn","panic","unit-struct"],"backgroundTag":"unsupported-deserializer-method","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}