{"record":{"id":"acba8e248713ba35","repo":"tracel-ai/burn","slug":"default-content-should-be-implemented-for-self-ty","errorCode":null,"errorMessage":"Default content should be implemented for {self_type}.","messagePattern":"Default content should be implemented for (.+?)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-core/src/module/display.rs","lineNumber":65,"sourceCode":"        } else {\n            passed_settings\n        };\n\n        let indent = \" \".repeat(settings.level * settings.indentation_size());\n        let indent_close_braces = \" \".repeat((settings.level - 1) * settings.indentation_size());\n\n        let settings = settings.level_up();\n\n        let self_type = extract_type_name::<Self>();\n\n        // Use custom content if it is implemented and show_all_attributes is false,\n        // otherwise use default content\n        let content = if !settings.show_all_attributes() {\n            self.custom_content(Content::new(settings.clone()))\n                .unwrap_or_else(|| {\n                    self.content(Content::new(settings.clone()))\n                        .unwrap_or_else(|| {\n                            panic!(\"Default content should be implemented for {self_type}.\")\n                        })\n                })\n        } else {\n            self.content(Content::new(settings.clone()))\n                .unwrap_or_else(|| panic!(\"Default content should be implemented for {self_type}.\"))\n        };\n\n        let top_level_type = if let Some(top_level_type) = content.top_level_type {\n            top_level_type.to_owned()\n        } else {\n            self_type.to_owned()\n        };\n\n        // If there is only one item in the content, return it or no attributes\n        if let Some(item) = content.single_item {\n            return item;\n        } else if content.attributes.is_empty() {\n            return top_level_type.to_string();","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-core/src/module/display.rs#L47-L83","documentation":"Module display formatting first tries `custom_content`, and when that returns None it falls back to `content()` (the default content renderer). This panic fires when a module (or its primitive) implements the display traits but returns None from `content`, i.e. the required default renderer is missing. It is a trait-implementation contract violation, not a runtime data problem.","triggerScenarios":"Implementing `ModuleDisplay`/`ModuleContent` (or a new primitive/backend tensor display) whose `content()` returns `None` while `show_all_attributes()` is false; a custom module that only overrides `custom_content` and never supplies default content; `format` called on a type whose content impl was forgotten after an API update.","commonSituations":"Printing/logging a custom module with `model.print()` or `{:#?}`-style display after upgrading burn and missing a new required `content` implementation; hand-written adapters around burn modules returning None unconditionally.","solutions":["Implement `content(...)` for the type named in {self_type} so it returns Some(Content) with at least the type name and parameters.","If the type intentionally has no content, wrap rendering so `content` returns a minimal Content instead of None.","Check the burn version's display trait requirements — an upgrade may have made `content` mandatory for your custom module."],"exampleFix":"// before\nimpl ModuleContent for MyLayer {\n    fn content(&self, _settings: &ContentSettings) -> Option<Content> { None } // panics\n}\n// after\nimpl ModuleContent for MyLayer {\n    fn content(&self, settings: &ContentSettings) -> Option<Content> {\n        Some(Content::new(settings.clone())\n            .add_top_level_type(\"MyLayer\")\n            .add_parameter(Param::new(\"in_features\", self.in_features)))\n    }\n}","handlingStrategy":"validation","validationCode":"// Before printing, assert your custom modules implement content\nfn check_content<M: ModuleContent>(m: &M, s: &ContentSettings) {\n    assert!(m.content(Content::new(s.clone())).is_some(), \"content() must be implemented\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always return Some(Content) from content() — use custom_content for extras","After upgrading burn, recompile: trait changes usually break custom display impls at compile time","Test display output (model.print()) in unit tests for custom modules"],"tags":["rust","burn","display","trait-implementation"],"backgroundTag":"missing-content-implementation","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"}