{"record":{"id":"7c0201adaae65a0d","repo":"neon-bindings/neon","slug":"class-export-can-only-be-applied-to-named-types","errorCode":null,"errorMessage":"Class export can only be applied to named types","messagePattern":"Class export can only be applied to named types","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/neon-macros/src/export/class.rs","lineNumber":89,"sourceCode":"        #class_tokens\n        #create_fn\n    )\n    .into()\n}\n\n// Extract the class identifier from an impl block\nfn extract_class_ident(input: &syn::ItemImpl) -> syn::Result<syn::Ident> {\n    match &*input.self_ty {\n        syn::Type::Path(syn::TypePath {\n            path: syn::Path { segments, .. },\n            ..\n        }) => {\n            let syn::PathSegment { ident, .. } = segments\n                .last()\n                .ok_or_else(|| syn::Error::new(input.self_ty.span(), \"Expected type name\"))?;\n            Ok(ident.clone())\n        }\n        _ => Err(syn::Error::new(\n            input.self_ty.span(),\n            \"Class export can only be applied to named types\",\n        )),\n    }\n}\n","sourceCodeStart":71,"sourceCodeEnd":95,"githubUrl":"https://github.com/neon-bindings/neon/blob/38960e4381d9ad13b551cdf2d261f609167c9bc2/crates/neon-macros/src/export/class.rs#L71-L95","documentation":"The class export macro only supports impls whose self type is a named path type (syn::Type::Path). Any other type form — references, tuples, slices, trait objects, pointers, etc. — is rejected with this message at the self type span.","triggerScenarios":"Writing #[neon] export on an `impl` for a non-path self type such as `impl &T`, `impl Box<T> as ...` malformed forms, `impl dyn Trait`, `impl [T]`, or `impl ()`.","commonSituations":"Trying to export a trait object or reference type; accidentally exporting an impl block intended for internal use; typos producing non-path types like extra `&` or parentheses.","solutions":["Apply the export only to a concrete named struct/enum: `impl MyType { ... }`","Remove `&`, `Box`, `dyn Trait`, or other wrappers from the self type","If exporting is not intended, drop the #[neon] export attribute from that impl"],"exampleFix":"// before\n#[neon]\nimpl dyn Greet { // not a named type\n    fn new(cx: &mut FunctionContext) -> JsResult<JsGreet> { ... }\n}\n// after\n#[neon]\nimpl Greet {\n    fn new(cx: &mut FunctionContext) -> JsResult<JsGreet> { ... }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// reject reference, tuple, slice, and trait-object self types\nfn is_exportable_self_type(ty: &syn::Type) -> bool {\n    matches!(ty, syn::Type::Path(p) if p.qself.is_none() && !p.path.segments.is_empty())\n}","tryCatchPattern":null,"preventionTips":["Only mark impls of concrete named types with #[neon] export","Strip `&`, `Box`, and `dyn Trait` wrappers before exporting","Keep export attributes off internal/helper impl blocks"],"tags":["rust","proc-macro","neon","self-type","compile-time"],"backgroundTag":"incompatible-source-type","analyzedSha":"38960e4381d9ad13b551cdf2d261f609167c9bc2","analyzedAt":"2026-09-13T09:05:33.640Z","contentChangedAt":"2026-09-13T09:05:33.640Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}