{"record":{"id":"b0208e02cc11ad12","repo":"tauri-apps/tauri","slug":"defaultruntime-requires-the-last-parameter-to-not","errorCode":null,"errorMessage":"DefaultRuntime requires the last parameter to not have a default value","messagePattern":"DefaultRuntime requires the last parameter to not have a default value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/runtime.rs","lineNumber":92,"sourceCode":"  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\n  let feature = attributes.feature.to_string();\n\n  quote!(\n    #[cfg(feature = #feature)]\n    #wry\n\n    #[cfg(not(feature = #feature))]\n    #input\n  )\n}\n","sourceCodeStart":74,"sourceCodeEnd":106,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/runtime.rs#L74-L106","documentation":"The #[tauri::default_runtime] macro requires the runtime type parameter on the annotated item to have no default value, since the macro itself supplies the default from the given feature/type attributes. If the last generic parameter already carries a default (e.g. `R = Wry`), the macro panics with this message instead of emitting conflicting defaults.","triggerScenarios":"Writing `pub struct App<R: Runtime = Wry> { ... }` and annotating it with #[default_runtime] (or applying default_runtime to an item whose last generic already has `= SomeType`).","commonSituations":"Copying a generic struct definition from non-macro code and adding default_runtime; upgrading Tauri and hand-porting runtime generics; IDE auto-inserting a default type parameter.","solutions":["Remove the `= Default` from the last generic parameter and let default_runtime supply it","Keep the `Runtime` bound on the parameter but no default","Check the generated item signature via cargo expand after removing the default"],"exampleFix":"// before\n#[default_runtime]\npub struct App<R: Runtime = Wry> { _r: std::marker::PhantomData<R> }\n// after\n#[default_runtime]\npub struct App<R: Runtime> { _r: std::marker::PhantomData<R> }","handlingStrategy":"validation","validationCode":"// In CI: fail builds if default_runtime items declare default generics\n// grep check:\n// if rg -U '#\\[default_runtime\\][\\s\\S]{0,200}<[^>]*=\\s*\\w+>' crates/; then exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write default values on generics of items annotated with default_runtime","Keep the bare `<R: Runtime>` convention when porting Tauri-internal types","Run cargo check (macro expansion) before committing macro changes"],"tags":["macros","generics","runtime","compile-time"],"backgroundTag":"conflicting-config-options","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"}