{"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":"  parse_quote, DeriveInput, Error, GenericParam, Ident, ItemTrait, ItemType, Token, Type, TypeParam,\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/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macros/src/runtime.rs#L9-L45","documentation":"#[default_runtime] (tauri-macros, re-exported by tauri; syntax like #[default_runtime(crate::Wry, wry)]) injects a default for the last generic parameter of an item so downstream users can omit the runtime type. The parser tries the input as DeriveInput (struct/enum), then ItemTrait, then ItemType; if all three fail — the item is a fn, impl, module, union, use — it reports 'default_runtime only supports `struct`, `enum`, `type`, or `trait` definitions'.","triggerScenarios":"Annotating an impl block, fn, mod, union, or use item with #[default_runtime]; the attribute only makes sense on definitions that own the generic parameter list being defaulted.","commonSituations":"Trying to get a defaulted runtime on associated functions or impls instead of the type definition; the attribute left behind after refactoring a type into something else; pasting it at the wrong nesting level.","solutions":["Move the attribute onto the struct/enum definition, trait, or type alias that actually carries the runtime generic","Ensure that item has at least one generic parameter — the macro defaults the last one and asserts on its presence","For functions, spell the runtime parameter explicitly instead of relying on the macro"],"exampleFix":"// before\n#[default_runtime(crate::Wry, wry)]\nimpl<R: Runtime> App<R> { /* ... */ }\n// after - annotate the type that owns the generic\n#[default_runtime(crate::Wry, wry)]\nstruct App<R: Runtime> { /* ... */ }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply #[default_runtime(...)] only to struct, enum, type alias, or trait definitions","Ensure the annotated item has a generic parameter — the last one is defaulted","Do not expect defaults on functions or impl blocks; specify the runtime explicitly there"],"tags":["macros","runtime","generics","compile-time","item-kind"],"backgroundTag":"unsupported-macro-input","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}