{"record":{"id":"d5329e59d03e2044","repo":"tauri-apps/tauri","slug":"only-named-wildcard-struct-and-tuple-struct-arg","errorCode":null,"errorMessage":"only named, wildcard, struct, and tuple struct arguments allowed","messagePattern":"only named, wildcard, struct, and tuple struct arguments allowed","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/command/wrapper.rs","lineNumber":484,"sourceCode":"  // we have no use for self arguments\n  let mut arg = match arg {\n    FnArg::Typed(arg) => arg.pat.as_ref().clone(),\n    FnArg::Receiver(arg) => {\n      return Err(syn::Error::new(\n        arg.span(),\n        \"unable to use self as a command function parameter\",\n      ));\n    }\n  };\n\n  // we only support patterns that allow us to extract some sort of keyed identifier\n  let mut key = match &mut arg {\n    Pat::Ident(arg) => arg.ident.unraw().to_string(),\n    Pat::Wild(_) => \"\".into(), // we always convert to camelCase, so \"_\" will end up empty anyways\n    Pat::Struct(s) => super::path_to_command(&mut s.path).ident.to_string(),\n    Pat::TupleStruct(s) => super::path_to_command(&mut s.path).ident.to_string(),\n    err => {\n      return Err(syn::Error::new(\n        err.span(),\n        \"only named, wildcard, struct, and tuple struct arguments allowed\",\n      ));\n    }\n  };\n\n  // also catch self arguments that use FnArg::Typed syntax\n  if key == \"self\" {\n    return Err(syn::Error::new(\n      key.span(),\n      \"unable to use self as a command function parameter\",\n    ));\n  }\n\n  match attributes.argument_case {\n    ArgumentCase::Camel => {\n      key = key.to_lower_camel_case();\n    }","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/command/wrapper.rs#L466-L502","documentation":"Command parameters must map to a named JS-observable key, so parse_arg supports only identifier patterns, wildcards (_), struct patterns, and tuple-struct patterns. Any other pattern (literals, slices, tuples, refs as patterns, etc.) fails with this compile-time error.","triggerScenarios":"Destructuring unsupported shapes in a command signature, e.g. fn cmd((a, b): (i32, i32)) (plain tuple), fn cmd([x, y]: [i32; 2]), fn cmd(1 = ...) style literal patterns, or reference patterns.","commonSituations":"Trying to accept destructured arrays/tuples from the frontend; auto-formatting or macro-generated code introducing non-ident patterns; porting a Rust API with tuple arguments into a command.","solutions":["Replace the unsupported pattern with a named struct or single named argument (define a struct parameter and destructure inside the body)","Use plain named arguments for each value instead of tuple/array destructuring","If only part of the value is needed, bind the whole argument to a name and destructure in the function body"],"exampleFix":"// before\n#[tauri::command]\nfn cmd((a, b): (i32, i32)) -> i32 { a + b }\n// after\n#[tauri::command]\nfn cmd(pair: PairArg) -> i32 { pair.a + pair.b }\n// with #[serde(rename_all=\"camelCase\")] struct PairArg { a: i32, b: i32 }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only named arguments in command signatures; destructure inside the body","Model complex payloads as serde structs rather than tuple/array patterns","Avoid macros/formatters that rewrite command parameter patterns"],"tags":["proc-macro","tauri","compile-time","patterns"],"backgroundTag":"invalid-argument-format","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}