{"record":{"id":"af37e5bfa13c7792","repo":"GraphiteEditor/Graphite","slug":"editor-commands-takes-no-arguments","errorCode":null,"errorMessage":"#[editor_commands] takes no arguments","messagePattern":"#\\[editor_commands\\] takes no arguments","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"proc-macros/src/editor_commands.rs","lineNumber":9,"sourceCode":"use convert_case::{Case, Casing};\nuse proc_macro2::TokenStream;\nuse quote::{quote, quote_spanned};\nuse syn::spanned::Spanned;\nuse syn::{Error, FnArg, Ident, Item, ItemFn, ItemMod, ItemUse, Pat, Visibility};\n\npub fn editor_commands_impl(attr: TokenStream, module: ItemMod) -> syn::Result<TokenStream> {\n\tif !attr.is_empty() {\n\t\treturn Err(Error::new(attr.span(), \"#[editor_commands] takes no arguments\"));\n\t}\n\tfor attr in &module.attrs {\n\t\tif !attr.path().is_ident(\"doc\") {\n\t\t\treturn Err(Error::new(attr.span(), \"the #[editor_commands] module may not have other attributes\"));\n\t\t}\n\t}\n\tlet Some((_, items)) = module.content else {\n\t\treturn Err(Error::new(module.mod_token.span, \"#[editor_commands] requires a module with an inline body\"));\n\t};\n\n\tlet mut imports: Vec<ItemUse> = Vec::new();\n\tlet mut functions: Vec<ItemFn> = Vec::new();\n\tfor item in items {\n\t\tmatch item {\n\t\t\tItem::Use(import) => imports.push(import),\n\t\t\tItem::Fn(function) => functions.push(function),\n\t\t\tother => return Err(Error::new(other.span(), \"only `use` imports and command functions may appear in an #[editor_commands] module\")),\n\t\t}","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/proc-macros/src/editor_commands.rs#L1-L27","documentation":"editor_commands_impl rejects any attribute argument: the macro must be written exactly as bare #[editor_commands]. Any token content inside #[editor_commands(...)] fails with this spanned error before the module is inspected.","triggerScenarios":"Writing #[editor_commands(SomeArg)] or an attribute-value form on the commands module.","commonSituations":"Trying to configure the macro per module (naming, scoping, feature flags) when it supports no options; autocomplete inserting parentheses with a placeholder argument.","solutions":["Remove the argument and use bare #[editor_commands]","If per-module configuration is needed, wrap or rename modules instead of passing arguments to the macro"],"exampleFix":"// before\n#[editor_commands(some_arg)]\nmod commands { /* ... */ }\n\n// after\n#[editor_commands]\nmod commands { /* ... */ }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write the macro exactly as #[editor_commands] — no parentheses, no arguments","Do not attempt per-module configuration through the attribute; it supports none"],"tags":["proc-macro","rust","attribute","compile-time","editor"],"backgroundTag":"macro-attribute-misuse","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}