{"record":{"id":"302d9e0a1311a219","repo":"tauri-apps/tauri","slug":"default-runtime-only-supports-struct-enum-t","errorCode":null,"errorMessage":"default_runtime only supports `struct`, `enum`, `type`, or `trait` definitions","messagePattern":"default_runtime only supports `struct`, `enum`, `type`, or `trait` definitions","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/runtime.rs","lineNumber":27,"sourceCode":"  DeriveInput, Error, GenericParam, Ident, ItemTrait, ItemType, Token, Type, TypeParam, parse_quote,\n};\n\n#[derive(Clone)]\npub(crate) enum Input {\n  Derive(DeriveInput),\n  Trait(ItemTrait),\n  Type(ItemType),\n}\n\nimpl Parse for Input {\n  fn parse(input: ParseStream) -> syn::Result<Self> {\n    input\n      .parse::<DeriveInput>()\n      .map(Self::Derive)\n      .or_else(|_| input.parse().map(Self::Trait))\n      .or_else(|_| input.parse().map(Self::Type))\n      .map_err(|_| {\n        Error::new(\n          input.span(),\n          \"default_runtime only supports `struct`, `enum`, `type`, or `trait` definitions\",\n        )\n      })\n  }\n}\n\nimpl Input {\n  fn last_param_mut(&mut self) -> Option<&mut GenericParam> {\n    match self {\n      Input::Derive(d) => d.generics.params.last_mut(),\n      Input::Trait(t) => t.generics.params.last_mut(),\n      Input::Type(t) => t.generics.params.last_mut(),\n    }\n  }\n}\n\nimpl ToTokens for Input {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/runtime.rs#L9-L45","documentation":"The `#[default_runtime]` macro only applies to item definitions it understands: struct, enum, type alias, or trait (parsed as DeriveInput, ItemTrait, or ItemType). Applying it to any other item (fn, mod, impl, const) makes parsing fail with this compile error.","triggerScenarios":"Attaching `#[default_runtime]` to a function, module, impl block, or static instead of a type definition.","commonSituations":"Placing the attribute on the wrong item by mistake; using editor auto-import/snippets that attach the attribute to the preceding item.","solutions":["Move the attribute onto a struct, enum, type, or trait definition","Remove the attribute if no type in the file needs the default runtime","If wrapping a function, look for the intended macro instead (e.g. tauri::command)"],"exampleFix":"// before\n#[default_runtime]\nfn init() {}\n// after\n#[default_runtime]\npub struct App<R: Runtime> { runtime: R }","handlingStrategy":"validation","validationCode":"// Only apply #[default_runtime] to type definitions\n// quick review checklist: the item under the attribute must start with struct/enum/type/trait","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place #[default_runtime] directly above struct/enum/type/trait items only","Move helper functions/modules away from attributed items to avoid misplacement","Let rust-analyzer's attribute support surface the error early via cargo check on save"],"tags":["compile-time","macro","attribute","invalid-target"],"backgroundTag":"invalid-argument-value","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"}