slint-ui/slint · error · syn::Error
VTable pointer need to be the first
Error message
VTable pointer need to be the first
What it means
Error "VTable pointer need to be the first" thrown in slint-ui/slint.
Source
Thrown at helper_crates/vtable/macro/macro.rs:318
Some((matches!(mutability, PointerMutability::Mut(_)), elem))
}
Type::Reference(TypeReference { mutability, elem, .. }) => {
Some((mutability.is_some(), elem))
}
_ => None,
};
if let Some((is_mut, elem)) = ptr_target
&& let Type::Path(p) = &**elem
&& let Some(pointer_to) = p.path.get_ident()
&& pointer_to == &vtable_name
{
if is_mut {
return Error::new(p.span(), "VTable cannot be mutable")
.to_compile_error()
.into();
}
if call_code.is_some() || !sig.inputs.is_empty() {
return Error::new(p.span(), "VTable pointer need to be the first")
.to_compile_error()
.into();
}
call_code = Some(quote!(vtable as _,));
continue;
}
let (is_pin, self_ty) = match is_pin(¶m.ty) {
Some(t) => (true, t),
None => (false, ¶m.ty),
};
// check for self
if let (true, mutability) = if match_generic_type(self_ty, "VRef", &vtable_name) {
(true, None)
} else if match_generic_type(self_ty, "VRefMut", &vtable_name) {
(true, Some(Default::default()))
} else {View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Place the vtable pointer as the first field of the struct.
- Reorder the struct fields accordingly.
When it happens
Trigger: Thrown at helper_crates/vtable/macro/macro.rs:318 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/fe37704215716218.
Report an issue: GitHub.