{"record":{"id":"fe37704215716218","repo":"slint-ui/slint","slug":"vtable-pointer-need-to-be-the-first","errorCode":null,"errorMessage":"VTable pointer need to be the first","messagePattern":"VTable pointer need to be the first","errorType":"exception","errorClass":"proc_macro::Error","httpStatus":null,"severity":"error","filePath":"helper_crates/vtable/macro/macro.rs","lineNumber":318,"sourceCode":"                        Some((matches!(mutability, PointerMutability::Mut(_)), elem))\n                    }\n                    Type::Reference(TypeReference { mutability, elem, .. }) => {\n                        Some((mutability.is_some(), elem))\n                    }\n                    _ => None,\n                };\n                if let Some((is_mut, elem)) = ptr_target\n                    && let Type::Path(p) = &**elem\n                    && let Some(pointer_to) = p.path.get_ident()\n                    && pointer_to == &vtable_name\n                {\n                    if is_mut {\n                        return Error::new(p.span(), \"VTable cannot be mutable\")\n                            .to_compile_error()\n                            .into();\n                    }\n                    if call_code.is_some() || !sig.inputs.is_empty() {\n                        return Error::new(p.span(), \"VTable pointer need to be the first\")\n                            .to_compile_error()\n                            .into();\n                    }\n                    call_code = Some(quote!(vtable as _,));\n                    continue;\n                }\n\n                let (is_pin, self_ty) = match is_pin(&param.ty) {\n                    Some(t) => (true, t),\n                    None => (false, &param.ty),\n                };\n\n                // check for self\n                if let (true, mutability) = if match_generic_type(self_ty, \"VRef\", &vtable_name) {\n                    (true, None)\n                } else if match_generic_type(self_ty, \"VRefMut\", &vtable_name) {\n                    (true, Some(Default::default()))\n                } else {","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/helper_crates/vtable/macro/macro.rs#L300-L336","documentation":"The macro treats a first parameter pointing to the vtable type as the implicit dispatch/self-slot and requires it to be the ONLY first parameter: it must appear before any other parameters, and the function must not be a #[call] entry (call_code). Encountering the vtable-pointer type in any other position, or in a function that already has a call target or other inputs, produces this compile error.","triggerScenarios":"Placing a `*const MyVTable` parameter after other arguments in a trait method signature; using the vtable-pointer form in the #[call] function which already has call_code set.","commonSituations":"Reordering parameters when adding context arguments; misunderstanding that the vtable pointer is positional and must lead the signature.","solutions":["Move the *const MyVTable parameter to be the first parameter of the method.","Remove extra parameters before the vtable pointer, or drop the vtable pointer if it is not needed.","Do not combine the vtable-pointer form with a #[call] designated function."],"exampleFix":"// before\nfn dispatch(arg: u32, vt: *const MyVTable);\n// after\nfn dispatch(vt: *const MyVTable, arg: u32);","handlingStrategy":"validation","validationCode":"// vtable pointer must be parameter #1 and not in the #[call] fn\nfn dispatch(vt: *const MyVTable, /* other args */);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the vtable pointer as the first parameter of any method that declares one.","Never put a vtable pointer parameter in the function marked #[call]."],"tags":["proc-macro","argument-order","compile-time","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}