{"record":{"id":"512c1f5455929da5","repo":"tracel-ai/burn","slug":"field-as-no-generic","errorCode":null,"errorMessage":"Field {} as no generic","messagePattern":"Field (.+?) as no generic","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-derive/src/shared/field.rs","lineNumber":31,"sourceCode":"    }\n\n    pub fn ident(&self) -> Ident {\n        self.field.ident.clone().unwrap()\n    }\n\n    pub fn is_of_type(&self, paths: &[&str]) -> bool {\n        match &self.field.ty {\n            syn::Type::Path(path) => {\n                let name = Self::path_name(path);\n                paths.contains(&name.as_str())\n            }\n            _ => false,\n        }\n    }\n\n    #[allow(dead_code)]\n    pub fn first_generic_field(&self) -> TypePath {\n        let err = || panic!(\"Field {} as no generic\", self.field.ident.clone().unwrap());\n        match &self.field.ty {\n            syn::Type::Path(path) => Self::path_generic_argument(path),\n            _ => err(),\n        }\n    }\n    pub fn path_generic_argument(path: &TypePath) -> TypePath {\n        let segment = path.path.segments.last().unwrap();\n        let err = || panic!(\"Path segment {} has no generic\", segment.ident.clone(),);\n        match &segment.arguments {\n            syn::PathArguments::None => err(),\n            syn::PathArguments::AngleBracketed(param) => {\n                let first_param = param.args.first().unwrap();\n\n                if let syn::GenericArgument::Type(Type::Path(path)) = first_param {\n                    path.clone()\n                } else {\n                    err()\n                }","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-derive/src/shared/field.rs#L13-L49","documentation":"Type-shape guard in the derive field helper: `first_generic_field` assumes the field's type is a generic path (e.g. `Linear<B>`) and panics with the field's name when the type path has no generic arguments (or the type is not a path at all, like a primitive). It fires at macro expansion when codegen expects a generic parameter that the field type does not provide; the input at fault is the non-generic field type.","triggerScenarios":"Thrown at crates/burn-derive/src/shared/field.rs:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the field type generic (e.g. `Param<Tensor<B, D>>` instead of a concrete type) so codegen can extract the backend generic.","If the field should not carry generics, avoid the code path calling `first_generic_field` for it (annotate with the appropriate skip/ignore attribute).","Check for typos that make the intended generic type resolve to a plain path."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}