{"record":{"id":"03e117f29b82995a","repo":"PyO3/pyo3","slug":"wildcard-argument-names-are-not-supported","errorCode":null,"errorMessage":"wildcard argument names are not supported","messagePattern":"wildcard argument names are not supported","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"pyo3-macros-backend/src/method.rs","lineNumber":214,"sourceCode":"                    #[cfg(feature = \"experimental-inspect\")]\n                    annotation: None,\n                }))\n            }\n        }\n    }\n}\n\nfn handle_argument_error(pat: &syn::Pat) -> syn::Error {\n    let span = pat.span();\n    let msg = match pat {\n        syn::Pat::Wild(_) => \"wildcard argument names are not supported\",\n        syn::Pat::Struct(_)\n        | syn::Pat::Tuple(_)\n        | syn::Pat::TupleStruct(_)\n        | syn::Pat::Slice(_) => \"destructuring in arguments is not supported\",\n        _ => \"unsupported argument\",\n    };\n    syn::Error::new(span, msg)\n}\n\n/// Represents what kind of a function a pyfunction or pymethod is\n#[derive(Clone, Debug)]\npub enum FnType {\n    /// Represents a pymethod annotated with `#[getter]`\n    Getter(SelfType),\n    /// Represents a pymethod annotated with `#[setter]`\n    Setter(SelfType),\n    /// Represents a pymethod annotated with `#[deleter]`\n    Deleter(SelfType),\n    /// Represents a regular pymethod\n    Fn(SelfType),\n    /// Represents a pymethod annotated with `#[classmethod]`, like a `@classmethod`\n    FnClass(Span),\n    /// Represents a pyfunction or a pymethod annotated with `#[staticmethod]`, like a `@staticmethod`\n    FnStatic,\n    /// Represents a pyfunction annotated with `#[pyo3(pass_module)]","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-macros-backend/src/method.rs#L196-L232","documentation":"pyo3's macro backend rejects function/method argument patterns it cannot turn into Python parameter bindings. A wildcard pattern (e.g. `_: Type` or `_name`) carries no identifier, so no Python argument name can be generated, so handle_argument_error errors during macro expansion of parse.","triggerScenarios":"Declaring a #[pyfunction]/#[pymethod] parameter with a wildcard pattern such as `_: usize`, or using a destructuring pattern (struct/tuple/slice) in the argument list.","commonSituations":"Copying Rust idioms like `_unused: i32` into pyfunctions; trying to destructure tuples directly in a pyfunction signature.","solutions":["Give every argument a real identifier (e.g. `_unused: usize` -> `unused: usize`)","Remove destructuring patterns; accept a named parameter and destructure in the body","For ignored Python args, name the parameter (e.g. `_unused`) — the leading underscore keeps Rust lint-clean"],"exampleFix":"// before\n#[pyfunction]\nfn process(_count: usize) -> usize { _count * 2 }\n// after\n#[pyfunction]\nfn process(count: usize) -> usize { count * 2 }","handlingStrategy":"validation","validationCode":"// compile-time macro error; validate signatures by convention before building\n// CI check: grep for wildcard params in pyfunctions\n// grep -rn 'fn .*(_ *[A-Za-z]' src/  # flag `_: Type` args in #[pyfunction]s","typeGuard":null,"tryCatchPattern":"// expand macros early to catch it in review\ncargo expand path::to::pyfunction 2>&1 | head -20","preventionTips":["Never use `_: Type` wildcard parameters in #[pyfunction]/#[pymethod] signatures","Prefix intentionally-unused args with an underscore name instead of `_`","Avoid destructuring patterns in pyfunction arguments","Run cargo check in CI so macro errors surface before release builds"],"tags":["rust","pyo3-macros","proc-macro","function-signature"],"backgroundTag":"invalid-function-signature","analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}