{"record":{"id":"f4978e9eb3b0e92b","repo":"tauri-apps/tauri","slug":"default-runtime-requires-the-item-to-have-at-least-1-generic","errorCode":null,"errorMessage":"default_runtime requires the item to have at least 1 generic parameter","messagePattern":"default_runtime requires the item to have at least 1 generic parameter","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/runtime.rs","lineNumber":77,"sourceCode":"}\n\nimpl Parse for Attributes {\n  fn parse(input: ParseStream<'_>) -> syn::Result<Self> {\n    let default_type = input.parse()?;\n    input.parse::<Token![,]>()?;\n    Ok(Attributes {\n      default_type,\n      feature: input.parse()?,\n    })\n  }\n}\n\npub(crate) fn default_runtime(attributes: Attributes, input: Input) -> TokenStream {\n  // create a new copy to manipulate for the wry feature flag\n  let mut wry = input.clone();\n  let wry_runtime = wry\n    .last_param_mut()\n    .expect(\"default_runtime requires the item to have at least 1 generic parameter\");\n\n  // set the default value of the last generic parameter to the provided runtime type\n  match wry_runtime {\n    GenericParam::Type(\n      param @ TypeParam {\n        eq_token: None,\n        default: None,\n        ..\n      },\n    ) => {\n      param.eq_token = Some(parse_quote!(=));\n      param.default = Some(attributes.default_type);\n    }\n    _ => {\n      panic!(\"DefaultRuntime requires the last parameter to not have a default value\")\n    }\n  };\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/runtime.rs#L59-L95","documentation":"The `#[default_runtime]` attribute macro in tauri-macros rewrites the last generic parameter of the annotated item to default to the configured runtime type (e.g. `Wry`). It panics when the item has no generic parameters at all, because there is nothing to rewrite.","triggerScenarios":"Applying `#[default_runtime(...)]` (directly or via `#[tauri::command]`-style wrappers that use it) to a struct/enum/type alias with zero generic parameters, or an item whose last generic is a lifetime/const rather than a type parameter.","commonSituations":"Hand-writing internal Tauri types without the `R: Runtime` generic after a copy-paste, or upgrading Tauri and defining a custom runtime-related type that previously had generics removed.","solutions":["Add at least one generic type parameter (conventionally `R: Runtime`) to the annotated item.","Ensure the generic is the LAST parameter so `last_param_mut` targets it.","Remove the `#[default_runtime]` attribute if the item genuinely should not be runtime-generic."],"exampleFix":"// before\n#[default_runtime(Wry)]\nstruct MyPlugin;\n\n// after\n#[default_runtime(Wry)]\nstruct MyPlugin<R: Runtime> { /* uses R */ }","handlingStrategy":"validation","validationCode":"// compile-time check: item must be generic over the runtime\nfn assert_generic<R: tauri::Runtime>() {}\nassert_generic::<tauri::Wry>(); // fails to compile if the type has no runtime generic","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always keep `R: Runtime` as the last generic parameter on types using #[default_runtime].","Copy generic signatures along with struct bodies when reusing Tauri internal types."],"tags":["proc-macro","generics","rust","compile-time"],"backgroundTag":"missing-required-argument","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"}