{"record":{"id":"085bdb9017ecbf76","repo":"swc-project/swc","slug":"failed-to-parse-input-as-deriveinput","errorCode":null,"errorMessage":"failed to parse input as DeriveInput","messagePattern":"failed to parse input as DeriveInput","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ast_node/src/lib.rs","lineNumber":19,"sourceCode":"#![deny(clippy::all)]\n#![recursion_limit = \"1024\"]\n\nextern crate proc_macro;\n\nuse quote::quote;\nuse swc_macros_common::prelude::*;\nuse syn::*;\n\nmod ast_node_macro;\nmod encoding;\nmod enum_deserialize;\nmod spanned;\n\n/// Derives [`swc_common::Spanned`]. See [`swc_common::Spanned`] for\n/// documentation.\n#[proc_macro_derive(Spanned, attributes(span))]\npub fn derive_spanned(input: proc_macro::TokenStream) -> proc_macro::TokenStream {\n    let input = parse::<DeriveInput>(input).expect(\"failed to parse input as DeriveInput\");\n\n    let item = self::spanned::derive(input);\n\n    print(\"derive(Spanned)\", item.into_token_stream())\n}\n\n/// Derives `serde::Deserialize` which is aware of `tag` based deserialization.\n#[proc_macro_derive(DeserializeEnum, attributes(tag, encoding))]\npub fn derive_deserialize_enum(input: proc_macro::TokenStream) -> proc_macro::TokenStream {\n    let input = parse::<DeriveInput>(input).expect(\"failed to parse input as DeriveInput\");\n\n    let item = enum_deserialize::expand(input);\n\n    print(\"derive(DeserializeEnum)\", item.into_token_stream())\n}\n\n#[proc_macro_derive(Encode, attributes(encoding))]\npub fn derive_encode(input: proc_macro::TokenStream) -> proc_macro::TokenStream {","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/ast_node/src/lib.rs#L1-L37","documentation":"Proc-macro panic in derive_spanned: the input TokenStream did not parse as a syn DeriveInput (e.g. the derive was attached to something other than a struct/enum/union, or malformed tokens), so parse::<DeriveInput>().expect aborted expansion.","triggerScenarios":"Thrown at crates/ast_node/src/lib.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Apply #[derive(Spanned)] only to plain structs, enums or unions","Ensure no other attribute/macro mangles the item before the derive runs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}